Customization
In the web application that I support, there are many AJAX calls to submit forms that look like this:
jQuery.post($form.attr("action"), $form.serialize())
.always(commonProcessing)
.done(function() {
});
The function commonProcessingsearches for the “well-known” parts in the JSON response and takes appropriate measures (the response may also include request information). He reads something like this:
function commonProcessing(result, outcome) {
switch (outcome) {
case "success":
if (result.notify) {
}
else if (...) ;
break;
case "error":
break;
}
}
Problem
HTTP - 400 - , , , " " .done ( 200 OK, , .done , "" "", "). (, notify , , ).
, HTTP jQuery , result jqXHR JSON.
: " , , , "? , , $.parseJSON(result.responseText), JSON, , jQuery, .