Suppose I have performed an AJAX call with jQuery in the following fashion:
key = 'boo'
$.ajax({
type: 'GET',
async: true,
url: '/output',
data: JSON.stringify({'location':key}),
success: function(data) {
}
});
I have a route in my Python App Engine code that receives the call on '/output', but how can I get it to access the data I've passed in the AJAX call? That is, how do I fill in the following:
class OutputRoute(webapp.RequestHandler):
def get(self):
# something goes here to get the data from above
Why are you JSON.stringifying your 'data' param? If you don't do that and instead write:
Then in your handler you can just write:
jQuery.ajax will take care of turning the object specified in the data parameter into query params (for a GET), and webapp.RequestHandler.request.get parses the query params.