@@ -44,33 +44,44 @@ $.ajaxSetup({
4444 }
4545 toastr . info ( "Loading page..." , '' , { timeOut : 0 } ) ;
4646 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 ) {
6755 toastr . remove ( ) ;
6856 if ( typeof Ladda != 'undefined' ) {
6957 Ladda . stopAll ( ) ;
7058 }
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+ } ) ;
7485 }
7586 }
7687} ) ;
0 commit comments