javascript - Catch status code in jquery.form.js -


i'm trying make form debugger app, , using jquery.form.js submit form.

but want catch status code on both success or error, how can it?

i tried this, sta variable returns 'success' or 'error', not status code expected, plz help.

$('form').ajaxsubmit({     success: function(res, sta, xhr, $form) {         $('#result-code').html(sta);         $('#result-content').html(res);     },     error: function(res, sta, xhr, $form) {         $('#result-code').html(sta);         $('#result-content').html(res);     } }); 

as @rainer rillke replied: solution below, notice parameters sequence received of error differ 1 success!

$('form').ajaxsubmit({     success: function(res, sta, xhr, $form) {         $('#result-code').html(xhr.status);         $('#result-content').html(res);     },     error: function(xhr) {         $('#result-code').html(xhr.status);         $('#result-content').html(xhr.responsetext);     } }); 

use xhr.status property of jqxhr.

$('form').ajaxsubmit({     success: function(res, sta, xhr, $form) {         $('#result-code').text(xhr.status);         $('#result-content').html(res);     },     error: function(xhr) {         $('#result-code').text(xhr.status);     } }); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -