Content negotiation, AJAX, and APIs

September 24th, 2007

I thought I was being so clever when I put a content-negotiated API into TradeUps.net, my web development playground. To put it simply, a page can return the same information in different formats, depending upon the HTTP Accept: header. For example, this profile page (view only in Firefox for now) responds to a standard browser request with an HTML document, but returns JSON when it sees Accept: application/json as a header. In this case, a script on the page calls the same URL (/user/admin) again to get the map data in javascript-friendly format. That's where the weirdness starts.

Read full entry »

Unobtrusive Permalinks

March 22nd, 2007

One of the problems with AJAX-style hash-based permalinks (as in use at WikiMapia) is that the browser's history becomes cluttered, and the user has to hit Back a large number of times to escape the page. By using location.replace, I've devised a way to keep the history pristine yet allow DOM-state permalinks.

Check out the demo. (Should be working now, thanks wioota.)