Add generic ajax error catcher for status code 500

This commit is contained in:
Ramon Gutierrez 2018-02-04 18:06:03 +08:00
parent 3ff7765d6c
commit 900471be54
31 changed files with 463 additions and 502 deletions

View file

@ -0,0 +1,14 @@
$(function() {
$(document).ajaxError(function(event, response, ajaxSettings, thrownError) {
switch (response.status) {
case 500:
default:
swal({
title: 'Whoops!',
text: 'We encountered a problem. Please contact technical support.',
type: 'error'
});
break;
}
});
});

View file

@ -694,6 +694,7 @@
<!--end::Page Vendors -->
<!--begin::Page Snippets -->
<script src="/assets/app/js/dashboard.js" type="text/javascript"></script>
<script src="/assets/js/common.js" type="text/javascript"></script>
<!--end::Page Snippets -->
<!--begin::Extra Scripts -->

View file

@ -86,6 +86,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -118,6 +119,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -86,6 +86,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -118,6 +119,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -86,6 +86,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -118,6 +119,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -264,6 +264,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -296,6 +297,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -171,12 +171,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -369,6 +369,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var json = response.responseJSON;
var errors = json.errors;
var nerrors = json.nerrors;
@ -462,6 +463,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -192,12 +192,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -269,6 +269,7 @@ $(function() {
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -301,6 +302,7 @@ $(function() {
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -154,12 +154,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -698,6 +698,7 @@ $(function() {
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -730,6 +731,7 @@ $(function() {
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -248,6 +248,7 @@ $(function() {
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -280,6 +281,7 @@ $(function() {
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -158,12 +158,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -114,6 +114,7 @@ $(function() {
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -146,6 +147,7 @@ $(function() {
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -146,12 +146,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -169,6 +169,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -201,6 +202,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -161,12 +161,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -116,6 +116,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -148,6 +149,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -133,12 +133,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -138,6 +138,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -170,6 +171,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -163,12 +163,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -184,6 +184,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -216,6 +217,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -165,12 +165,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -86,6 +86,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -118,6 +119,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -137,12 +137,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});

View file

@ -122,6 +122,7 @@
}
});
}).fail(function(response) {
if (response.status == 422) {
var errors = response.responseJSON.errors;
var firstfield = false;
@ -154,6 +155,7 @@
$('html, body').animate({
scrollTop: $(firstfield).offset().top - 200
}, 100);
}
});
});

View file

@ -145,12 +145,6 @@
}).done(function(response) {
table.row(btn.parents('tr')).remove();
table.reload();
}).fail(function() {
swal({
title: 'Whoops',
text: 'An error occurred while deleting this item. Please contact support.',
type: 'error'
});
});
}
});