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
Post a Comment