Returning JSON from JavaScript to Python

Posted by Chris Lacy on Stack Overflow See other posts from Stack Overflow or by Chris Lacy
Published on 2010-05-09T05:36:56Z Indexed on 2010/05/09 5:48 UTC
Read the original article Hit count: 191

I'm writing a simple App Engine app.

I have a simple page that allows a user to move a marker on a Google map instance. Each time the user drops the marker, I want to return the long/lat to my Python app.

function initialize() {

  ... // Init map

  var marker = new GMarker(center, {draggable: true});
  GEvent.addListener(marker, "dragend", function() {
    // I want to return the marker.x/y to my app when this function is called ..
  });

}

To my (admittedly limited) knowledge, I should be:

1). Returning a JSON structure with my required data in the listener callback above

2). In my webapp.RequestHandler Handler class, trying to retrieve the JSON structure during the post method.

I would very much like to pass this JSOn data back to the app without causing a page reload (which is what has happened when I've used various post/form.submit methods so far).

Can anyone provide me with some psuedo code or an example on how I might achieve what I'm after?

Thanks.

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about python