Browse Source

makes the regular expression more flexible

Thomas 14 years ago
parent
commit
6578ce934a
1 changed files with 3 additions and 4 deletions
  1. 3 4
      Resources/public/jquery/jquery.form.js

+ 3 - 4
Resources/public/jquery/jquery.form.js

@@ -368,7 +368,6 @@ $.fn.ajaxSubmit = function(options) {
 				else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
 					xhr.responseXML = toXml(xhr.responseText);
 				}
-				
 				data = httpData(xhr, s.dataType, s);
 			}
 			catch(e){
@@ -438,10 +437,10 @@ $.fn.ajaxSubmit = function(options) {
                 // -- custom hack to make the ajax request works with non typed dataType
                 // author : Thomas Rabaix <thomas.rabaix@sonata-project.org>
                 // account for browsers injecting pre around json response
-                var matches = xhr.responseText.match(/^(<pre>|<body>)(.*)(<\/pre>|<\/body>)$/);
+                var matches = xhr.responseText.match(/^(<pre([^>]*)>|<body([^>]*)>)(.*)(<\/pre>|<\/body>)$/);
 
-                if(matches.length == 4){
-                    xhr.responseText = matches[2];
+                if(matches && matches.length == 6){
+                    xhr.responseText = matches[4];
                 }
 
                 if(xhr.responseText[0] == '{') {