Returning JSON from JavaScript to Python
- by Chris Lacy
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.