Skip to content
This repository
Browse code

MINOR Skip processing in CMS on empty ajax responses, as they're usua…

…lly a pseudo redirect (via X-ControllerURL)
  • Loading branch information...
commit aebbb10c9f65a67497e3ea5b3ab0256d3c5ebba0 1 parent e01b0aa
Ingo Schommer authored April 05, 2012
6  admin/javascript/LeftAndMain.Content.js
@@ -83,11 +83,11 @@
83 83
 			 *  (XMLHTTPRequest) xmlhttp
84 84
 			 */
85 85
 			loadForm_responseHandler: function(oldForm, html, status, xmlhttp) {
  86
+				if(!html) return;
86 87
 
87 88
 				if(oldForm.length > 0) {
88 89
 					oldForm.replaceWith(html); // triggers onmatch() on form
89  
-				}
90  
-				else {
  90
+				} else {
91 91
 					 $('.cms-content').append(html);
92 92
 				}
93 93
 				
@@ -199,6 +199,8 @@
199 199
 			 */
200 200
 			submitForm_responseHandler: function(oldForm, data, status, xmlhttp, origData) {
201 201
 				if(status == 'success') {
  202
+					if(!data) return;
  203
+
202 204
 					var form, newContent = $(data);
203 205
 
204 206
 					// HACK If response contains toplevel panel rather than a form, replace it instead.
4  admin/javascript/LeftAndMain.js
@@ -227,6 +227,10 @@ jQuery.noConflict();
227 227
 					headers: headers,
228 228
 					url: state.url,
229 229
 					success: function(data, status, xhr) {
  230
+						// Pseudo-redirects via X-ControllerURL might return empty data, in which
  231
+						// case we'll ignore the response
  232
+						if(!data) return;
  233
+
230 234
 						// Update title
231 235
 						var title = xhr.getResponseHeader('X-Title');
232 236
 						if(title) document.title = title;

0 notes on commit aebbb10

Please sign in to comment.
Something went wrong with that request. Please try again.