Guest User

Untitled

a guest
May 21st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. $.ajax({
  2. type: "POST",
  3. url: 'https://api.postcodes.io/postcodes/BS16AA',
  4. success: function (response) {
  5. console.log(response);
  6. },
  7. error: function (xhr, ajaxOptions, thrownError) {
  8. var msg = '';
  9. if (xhr.status === 0) {
  10. msg = 'Not connect.n Verify Network.';
  11. } else if (xhr.status == 404) {
  12. msg = 'Requested page not found. [404]';
  13. } else if (xhr.status == 500) {
  14. msg = 'Internal Server Error [500].';
  15. } else if (thrownError === 'parsererror') {
  16. msg = 'Requested JSON parse failed.';
  17. } else if (thrownError === 'timeout') {
  18. msg = 'Time out error.';
  19. } else if (thrownError === 'abort') {
  20. msg = 'Ajax request aborted.';
  21. } else {
  22. msg = 'Uncaught Error.n' + xhr.responseText;
  23. }
  24. }
  25. });
Add Comment
Please, Sign In to add comment