Content negotiation, AJAX, and APIs
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.