> Is there a standard way to detect if a request was an ajax one? I > know I could append a key to the ajax request like in Mr. Bennett's > post here: > > http://www.b-list.org/weblog/2006/07/31/django-tips-simple-ajax-example-part-1 > > ie http://website.com/some/request/?xhr and in my view, dump out json > accordingly, etc, but I was wondering if there was a standard way > without attaching a key (perhaps looking at a request header).
One of the beauties of the web is that a request is a request is a request. Information can be transmitted in the URL, in cookies, or in HTTP-authentication. One might also be able to tweak the other HTTP headers. My interpretation of the web philosophy says that you want to refer to the resource: http://example.com/path/to/resource If you want to alter the format, you can either make it a pseudo-resource: http://example.com/path/to/resource/json or pass it as a parameter: http://example.com/path/to/resource?format=json I tend to prefer the latter, because it's clearly the same resource, just changed-up a bit in the formatting dimension (plain-text, HTML, XML, JSON, YAML, CSV, tab-delimited, etc). I do similarly for sorting options: http://example.com/path/to/resource?order=fieldname Just my $0.02 -tkc --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---