Skip to content

Instantly share code, notes, and snippets.

@rajvanshipradeep15
Created November 21, 2018 05:17
Show Gist options
  • Save rajvanshipradeep15/61d56352efa10598d0ce2af0ab4e96db to your computer and use it in GitHub Desktop.
Save rajvanshipradeep15/61d56352efa10598d0ce2af0ab4e96db to your computer and use it in GitHub Desktop.
how you get JSON data on error
Here's an example of how you get JSON data on error:
$.ajax({
url: '/path/to/script.php',
data: {'my':'data'},
type: 'POST'
}).fail(function($xhr) {
var data = $xhr.responseJSON;
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment