Hi,
It seems that there are no error handling facility in the Jquery.Form plugin, which is very frustrating. Even though the documentation says we can use the $.ajax options, I still cannot make use of the 'error' option when the server returns an error, especially the 500 and 400 series. Is it that this plugin cannot handle any error at all from the server or is it a bug, etc? Can someone please tell me how I can handle errors (400, 500, etc) with this plugin? I need your help... All I want is a simple error handling... Thank you.
$("#uploadingImg").hide();
var options = {//Define ajax options
type: "post",
target: "#responsePanel",
beforeSend: function(){
$("#uploadingImg").show();
},
complete: function(xhr, textStatus){
$("#uploadingImg").hide();
},
success: function(response, statusString, xhr, $form){
// I know what to do here since this option works fine
},
error: function(response, status, err){
// This option doesn't catch any of the error below,
// everything is always 'OK' a.k.a 200
if(response.status == 400){
console.log("Sorry, this is bad request!");
}
if(response.status == 601){
sessionTimedOut();
}
}
}
$("#polygonUploadForm").submit(function(){
$(this).ajaxSubmit(options); // Using the jquery.form plugin
return false;
});