MINOR Skip processing in CMS on empty ajax responses, as they're usually a pseudo redirect (via X-ControllerURL)

This commit is contained in:
Ingo Schommer 2012-04-05 22:13:56 +02:00
parent e01b0aa3d0
commit aebbb10c9f
2 changed files with 8 additions and 2 deletions

View File

@ -83,11 +83,11 @@
* (XMLHTTPRequest) xmlhttp * (XMLHTTPRequest) xmlhttp
*/ */
loadForm_responseHandler: function(oldForm, html, status, xmlhttp) { loadForm_responseHandler: function(oldForm, html, status, xmlhttp) {
if(!html) return;
if(oldForm.length > 0) { if(oldForm.length > 0) {
oldForm.replaceWith(html); // triggers onmatch() on form oldForm.replaceWith(html); // triggers onmatch() on form
} } else {
else {
$('.cms-content').append(html); $('.cms-content').append(html);
} }
@ -199,6 +199,8 @@
*/ */
submitForm_responseHandler: function(oldForm, data, status, xmlhttp, origData) { submitForm_responseHandler: function(oldForm, data, status, xmlhttp, origData) {
if(status == 'success') { if(status == 'success') {
if(!data) return;
var form, newContent = $(data); var form, newContent = $(data);
// HACK If response contains toplevel panel rather than a form, replace it instead. // HACK If response contains toplevel panel rather than a form, replace it instead.

View File

@ -227,6 +227,10 @@ jQuery.noConflict();
headers: headers, headers: headers,
url: state.url, url: state.url,
success: function(data, status, xhr) { success: function(data, status, xhr) {
// Pseudo-redirects via X-ControllerURL might return empty data, in which
// case we'll ignore the response
if(!data) return;
// Update title // Update title
var title = xhr.getResponseHeader('X-Title'); var title = xhr.getResponseHeader('X-Title');
if(title) document.title = title; if(title) document.title = title;