From: John Resig Date: Thu, 18 Oct 2007 00:07:45 +0000 (+0000) Subject: Fix for bug #1638, where a non-string data could break an Ajax request. X-Git-Url: http://git.asbjorn.biz/?a=commitdiff_plain;h=80a26a326696599dad5b0bf88f8fa8e242e711e5;hp=14b88f6019cd467c35a2c9e845740a61c153525e;p=jquery.git Fix for bug #1638, where a non-string data could break an Ajax request. --- diff --git a/src/ajax.js b/src/ajax.js index 8261b44..09aba141 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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