Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- type: "POST",
- url: 'https://api.postcodes.io/postcodes/BS16AA',
- success: function (response) {
- console.log(response);
- },
- error: function (xhr, ajaxOptions, thrownError) {
- var msg = '';
- if (xhr.status === 0) {
- msg = 'Not connect.n Verify Network.';
- } else if (xhr.status == 404) {
- msg = 'Requested page not found. [404]';
- } else if (xhr.status == 500) {
- msg = 'Internal Server Error [500].';
- } else if (thrownError === 'parsererror') {
- msg = 'Requested JSON parse failed.';
- } else if (thrownError === 'timeout') {
- msg = 'Time out error.';
- } else if (thrownError === 'abort') {
- msg = 'Ajax request aborted.';
- } else {
- msg = 'Uncaught Error.n' + xhr.responseText;
- }
- }
- });
Add Comment
Please, Sign In to add comment