I'm trying to make a form debugger to my app, and using jquery.form.js to submit the form.
But I want to catch the status code on both success or error, how can I do it?
I tried this, but the sta variable only returns the 'success' or 'error', not the status code I 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: the solution is below, notice that the parameters sequence received of error is differ from the one with 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);
}
});
xhr.statusandxhr.statusTextproperties of the jqXHR.