Dynamically creating form in JQuery and posting it with JSON
On the jQuery API documentation, re the callback function:
success(data, textStatus, jqXHR) A callback function that is executed if the request succeeds.
Maybe adding a fail listener will help:
$.getJSON( $($form).get(0).action + "?callback=?", $($form).serialize(), function (data) { if (data.Status === 400) { alert("Error: " + data.Message); } else { // 200 alert("Success: " + data.Message); } }).error(function(data) { alert('have error http: ' + data);}).complete(function(data){ alert('have complete: ' + data);});
Update:
May also have something to do with a JSON error. From the API doc:
Important: As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently.
Switching to a $.get(...)
call might test this theory.