Handling Ajax HTTP Error Response


/ Published in: jQuery
Save to your folder(s)

Example of how to display HTTP error code and message on ajax response


Copy this code and paste it in your HTML
  1. $j.ajax({url: req,
  2. type: "POST",
  3. dataType: "json",
  4. data: "image=" + image + "&lbox=" + lboxVal,
  5. success: good_response,
  6. error: error_response});
  7.  
  8. function error_response(xhr,status)
  9. {
  10. //display http error and message from xhr object
  11. alert('HTTP ' + xhr.status + ' Error Encountered: ' + xhr.statusText);
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.