diff --git a/ecrire/inc/headers.php b/ecrire/inc/headers.php index fc24faae0ccdc7adad459a0b5eb9ddbdb5f6e9e0..759be7ab83b277c41db64f4872cb6e25b2b63027 100644 --- a/ecrire/inc/headers.php +++ b/ecrire/inc/headers.php @@ -205,6 +205,7 @@ function http_status($status) { 301 => '301 Moved Permanently', 302 => '302 Found', 304 => '304 Not Modified', + 400 => '400 Bad Request', 401 => '401 Unauthorized', 403 => '403 Forbidden', 404 => '404 Not Found', diff --git a/ecrire/public/aiguiller.php b/ecrire/public/aiguiller.php index d42ca099c2243e87db51f7a1e3116ccf062d5d7c..d9143ba83ce96d9f066998b97431ef21e0d13a74 100644 --- a/ecrire/public/aiguiller.php +++ b/ecrire/public/aiguiller.php @@ -149,7 +149,7 @@ function traiter_appels_inclusions_ajax() { } } else { include_spip('inc/headers'); - http_status(403); + http_status(400); $texte = _L('signature ajax bloc incorrecte'); } ajax_retour($texte, false); diff --git a/prive/javascript/ajaxCallback.js b/prive/javascript/ajaxCallback.js index 898f17680dae8751e620579e9d8dcbf73b1f41d9..43469f9a9da412ed84d4bfd6708ac8bdd21ae6ad 100644 --- a/prive/javascript/ajaxCallback.js +++ b/prive/javascript/ajaxCallback.js @@ -518,6 +518,20 @@ jQuery.spip.on_ajax_loaded = function(blocfrag,c,href,history) { jQuery.spip.updateReaderBuffer(); } +jQuery.spip.on_ajax_failed = function(blocfrag,statusCode,href,history) { + // marquer le bloc invalide + jQuery(blocfrag).addClass('invalid'); + // si c'est une erreur 400 on a perdu la signature ajax + //console.log("AJAX Erreur"); + //console.log(statusCode); + history = history || (history==null); + // quelle que soit l'erreur, on redirige si c'était la nouvelle URL principale de la page + if (history) { + //console.log("On redirige : " + href); + window.location.href = href; + } +} + jQuery.spip.stateId=0; jQuery.spip.setHistoryState = function(blocfrag){ if (!window.history.replaceState) return; @@ -611,8 +625,9 @@ jQuery.spip.loadAjax = function(blocfrag,url, href, options){ if (options.callback && typeof options.callback == "function") options.callback.apply(blocfrag); }, - error: function(){ + error: function(e){ jQuery.spip.preloaded_urls[url]=''; + jQuery.spip.on_ajax_failed(blocfrag,e.status,href,options.history); } }); }