Search code examples
pythongoogle-app-enginejqueryjquery-post

jQuery Post With Data Returned (json, xml etc) with Google App Engine (Python)


I've done jQuery post successfully. However, in order to get the data returned from server side. Can anyone gives example how this can be done in Google App Engine (Python) using webapp framework?

If possible, I need example:

  1. How we can send json data to template.
  2. From template, how we can access the json after jQuery post success function.
  3. I would appreciate very very much if anyone could post it to http://jsfiddle.net

Solution

  • I was actually looking for an answer how to get back the Json object from server side to the jQuery ajax post that I've written. So, here I figured out what went wrong from my earlier solution:

    Hence, the solution was simply:

    $.post("POST_URL", $("#form").serialize(),
            function(data){
                 alert(data); //data returned from server side
            }, "json");
    

    So, 2 mistakes I did:

    1. So, earlier the last parameter "json' was abandoned.
    2. After import django.utils.simplejson as json, I did one silly careless mistake where I used simplejson.dumps instead of json.dumps. (Basically, the wrong variable)