]> source.dussan.org Git - jquery.git/commitdiff
Fix for bug #1638, where a non-string data could break an Ajax request.
authorJohn Resig <jeresig@gmail.com>
Thu, 18 Oct 2007 00:07:45 +0000 (00:07 +0000)
committerJohn Resig <jeresig@gmail.com>
Thu, 18 Oct 2007 00:07:45 +0000 (00:07 +0000)
src/ajax.js

index 8261b44cc8efc5fecf6b375006e3a3e3fd655bb7..09aba1410777a959b356e1e1a742acae4e3820a8 100644 (file)
@@ -174,12 +174,12 @@ jQuery.extend({
                }
 
                // Build temporary JSONP function
-               if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
+               if ( s.dataType == "json" && (s.data && jsre.test( s.data ) || s.url.match(jsre)) ) {
                        jsonp = "jsonp" + jsc++;
 
                        // Replace the =? sequence both in the query string and the data
                        if ( s.data )
-                               s.data = s.data.replace(jsre, "=" + jsonp);
+                               s.data = (s.data + "").replace(jsre, "=" + jsonp);
                        s.url = s.url.replace(jsre, "=" + jsonp);
 
                        // We need to make sure