JQuery - How to simulate an error event for ajaxSubmit

I use ajaxSubmit to submit my form and would like to check if the event returns an error.

var options = { beforeSubmit: showRequest, // pre-submit callback success: showResponse, // post-submit callback error: printError, url: '../validation.php' }; $('#form1').submit(function () { $(this).ajaxSubmit(options); return false; }); 

In other words, I need to know how to simulate an error event so that I can test the printError function.

thanks

+6
jquery
source share
3 answers

returns an error code from your php script using the header operator. for example

 header('HTTP/1.0 403 Forbidden'); 

or

 header('HTTP/1.0 404 Not found'); 
+7
source share

..... try pointing the AJAX request to the wrong url? I think this will work.

+7
source share

You can use the Fiddler autoresponder to intercept XHR and simulate various error responses. This is especially useful if you do not want (or cannot) interfere with the server-side code.

0
source share

All Articles