@@ -70,11 +70,15 @@ protected function _ajax($method, $url, $responseElement = '', $parameters = [])
70
70
}
71
71
$ this ->createAjaxParameters ($ ajaxParameters , $ parameters );
72
72
$ retour .= "$.ajax({ " . $ this ->implodeAjaxParameters ($ ajaxParameters ) . "}).done(function( data, textStatus, jqXHR ) { \n" ;
73
- $ retour .= $ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone , $ ajaxTransition , $ jsCallback , $ hasLoader , ($ historize ? $ originalSelector : null )) . "}); \n" ;
74
-
73
+ $ retour .= $ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone , $ ajaxTransition , $ jsCallback , $ hasLoader , ($ historize ? $ originalSelector : null )) . "}) " ;
74
+ if (isset ($ error )) {
75
+ $ retour .= '.fail(function( jqXHR, textStatus, errorThrown ){ ' . $ error . '}) ' ;
76
+ }
77
+ $ retour .= "; \n" ;
75
78
$ retour = $ this ->_addJsCondition ($ jsCondition , $ retour );
76
- if ($ immediatly )
79
+ if ($ immediatly ) {
77
80
$ this ->jquery_code_for_compile [] = $ retour ;
81
+ }
78
82
return $ retour ;
79
83
}
80
84
@@ -817,8 +821,11 @@ private function _postForm($url, $form, $responseElement, $parameters = []) {
817
821
}
818
822
$ this ->createAjaxParameters ($ ajaxParameters , $ parameters );
819
823
$ retour .= "$.ajax({ " . $ this ->implodeAjaxParameters ($ ajaxParameters ) . "}).done(function( data ) { \n" ;
820
- $ retour .= $ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone , $ ajaxTransition , $ jsCallback , $ hasLoader ) . "}); \n" ;
821
-
824
+ $ retour .= $ this ->_getOnAjaxDone ($ responseElement , $ jqueryDone , $ ajaxTransition , $ jsCallback , $ hasLoader ) . "}) " ;
825
+ if (isset ($ error )) {
826
+ $ retour .= '.fail(function( jqXHR, textStatus, errorThrown ){ ' . $ error . '}) ' ;
827
+ }
828
+ $ retour .= "; \n" ;
822
829
if ($ validation ) {
823
830
$ retour = "$('#'+ " . $ form . ").validate({submitHandler: function(form) {
824
831
" . $ retour . "
0 commit comments