@@ -44,33 +44,44 @@ $.ajaxSetup({
44
44
}
45
45
toastr . info ( "Loading page..." , '' , { timeOut : 0 } ) ;
46
46
window . location . href = jqXHR . responseText ;
47
- } else {
48
- switch ( textStatus ) {
49
- case 'error' :
50
- // Server errors.
51
- if ( jqXHR . status >= 500 ) {
52
- toastr . remove ( ) ;
53
- if ( typeof Ladda != 'undefined' ) {
54
- Ladda . stopAll ( ) ;
55
- }
56
- toastr . error ( "Houston, we have a problem." , 'An error occurred :(' , { timeOut : 0 } ) ;
57
- }
58
- break ;
59
- case 'timeout' :
60
- toastr . remove ( ) ;
61
- if ( typeof Ladda != 'undefined' ) {
62
- Ladda . stopAll ( ) ;
63
- }
64
- toastr . error ( "Looks like we got stuck in the slow lane." , 'A timeout occurred :(' , { timeOut : 0 } ) ;
65
- break ;
66
- case 'parsererror' :
47
+
48
+ return ;
49
+ }
50
+
51
+ switch ( textStatus ) {
52
+ case 'error' :
53
+ // Server errors.
54
+ if ( jqXHR . status >= 500 ) {
67
55
toastr . remove ( ) ;
68
56
if ( typeof Ladda != 'undefined' ) {
69
57
Ladda . stopAll ( ) ;
70
58
}
71
- toastr . error ( "Looks like we got hit by a bug. Call the IT Support team." , 'A data error occurred :(' , { timeOut : 0 } ) ;
72
- break ;
73
- }
59
+ toastr . error ( "Houston, we have a problem." , 'An error occurred :(' , { timeOut : 0 } ) ;
60
+ }
61
+ break ;
62
+ case 'timeout' :
63
+ toastr . remove ( ) ;
64
+ if ( typeof Ladda != 'undefined' ) {
65
+ Ladda . stopAll ( ) ;
66
+ }
67
+ toastr . error ( "Looks like we got stuck in the slow lane." , 'A timeout occurred :(' , { timeOut : 0 } ) ;
68
+ break ;
69
+ case 'parsererror' :
70
+ toastr . remove ( ) ;
71
+ if ( typeof Ladda != 'undefined' ) {
72
+ Ladda . stopAll ( ) ;
73
+ }
74
+ toastr . error ( "Looks like we got hit by a bug. Call the IT Support team." , 'A data error occurred :(' , { timeOut : 0 } ) ;
75
+ break ;
76
+ }
77
+
78
+ if ( jqXHR . getResponseHeader ( 'X-TOASTR' ) != '' ) {
79
+ var toastr_messages = JSON . parse ( jqXHR . getResponseHeader ( 'X-TOASTR' ) ) ;
80
+ toastr . remove ( ) ;
81
+
82
+ $ . each ( toastr_messages , function ( key , value ) {
83
+ toastr [ key ] ( value ) ;
84
+ } ) ;
74
85
}
75
86
}
76
87
} ) ;
0 commit comments