Skip to content Skip to sidebar Skip to footer

Handling Json Form With Jquery On Google App Engine

I am having some problems with making jQuery work on GAE python 2.7 . The main problem is jQuery cant catch the json data returned by the server. A simple comment form with nothing

Solution 1:

You need to cancel the default action of the form, which is to submit (which cancels any running JavaScript AJAX query in progress):

$("#submit").click(function() {
    $.ajax({
     dataType: 'json',
     beforeSubmit: function() {
     },
     timeout: 60000,
     error: function(request,error) {
     },
      success: function(data) {
       var obj = jQuery.parseJSON(data);
       //blah blah...
       } // End success
    }); // End ajax methodreturnfalse; // Cancel default action.
});

By returning false from the click handler, the normal form action, which is for the browser to submit the data to the URL named in the action attribute, is not executed.

Post a Comment for "Handling Json Form With Jquery On Google App Engine"