I am making an API for some AJAX related things in my web app on GAE in Python. After setting the content-type to 'application/json' and accessing my url directly-
http://mysite.com/api?method=theMethod&param=firstParam
-I am being prompted with a 'save file' dialog box instead of seeing the JSON object displayed. The file contains the JSON object when opened in notepad.
Is this a correct way to return JSON from Python using GAE to be parsed in JavaScript?
from django.utils import simplejson
self.response.headers['Content-Type'] = 'application/json'
jsonData = {"foo" : "bar"}
self.response.out.write(simplejson.dumps(jsonData))
I have noticed that when using another API from somewhere else such as Flickr, my browser displays the JSON object rather than asking for me to save the file. This behavior is what encouraged me to investigate my implementation. My only thought is that this is related to a JSONP implementation.
Judging from rfc4627, I should be using 'application/json'.