Add generic ajax error catcher for status code 500
This commit is contained in:
parent
3ff7765d6c
commit
900471be54
31 changed files with 463 additions and 502 deletions
14
public/assets/js/common.js
Normal file
14
public/assets/js/common.js
Normal 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;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -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 -->
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue