Suor / handy

Handy django tools
BSD 3-Clause "New" or "Revised" License
85 stars 14 forks source link

JSON content type #3

Closed vgarvardt closed 11 years ago

vgarvardt commented 12 years ago

Why there is text/plain content type for decorators.render_to_json? JSON response should have application/json type to determine automatically on client side (e.g. with jQuery.ajax)

Suor commented 12 years ago

Ajax response with application/json content type opens a file save dialog in some old IEs. So I switched to text/plan and reinforce json data type on client manually.

nuklea commented 12 years ago

Maybe text/javascript better? IE understood that.

Suor commented 12 years ago

Does text/javascript works better with jquery or some other lib? Is there a point?

vgarvardt commented 12 years ago

What about setting for legacy browsers? Old IEs are rare for now, so legacy compatibility will be used very seldom. Something like:

content_type = '%s; charset=utf-8' % 'text/plain' if getattr(settings, 'HANDY_LEGACY_AJAX_CT', False) else 'application/json'
Suor commented 12 years ago

I am unwilling to add new settings. Is this really useful?