X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=a41de4cdc46d3554a9acf321c34b32cee1d8a490;hb=ec7fdf37235583a807b3f08e146edaadc81ca974;hp=beed45fbfdf596b269924836a3c0ba75ea74f5da;hpb=c3c94823f27ee1e935586d46fd86f055f3a3d97d;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index beed45f..a41de4c 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -187,15 +187,15 @@ jQuery.extend({ // Handle JSONP Parameter Callbacks if ( s.dataType == "jsonp" ) { if ( type == "GET" ) { - if ( !s.url.match(jsre) ) - s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; - } else if ( !s.data || !s.data.match(jsre) ) + if ( jsre.test( !s.url ) ) + s.url += (/\?/.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; + } else if ( !s.data || !jsre.test(s.data) ) s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; s.dataType = "json"; } // 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) || jsre.test(s.url)) ) { jsonp = "jsonp" + jsc++; // Replace the =? sequence both in the query string and the data @@ -228,12 +228,12 @@ jQuery.extend({ // try replacing _= if it is there var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); // if nothing was replaced, add timestamp to the end - s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); + s.url = ret + ((ret == s.url) ? (/\?/.test(s.url) ? "&" : "?") + "_=" + ts : ""); } // If data is available, append data to url for get requests if ( s.data && type == "GET" ) { - s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; + s.url += (/\?/.test(s.url) ? "&" : "?") + s.data; } // Watch for a new set of requests @@ -481,7 +481,7 @@ jQuery.extend({ xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, data = xml ? xhr.responseXML : xhr.responseText; - if ( xml && data.documentElement.tagName == "parsererror" ) { + if ( xml && data.documentElement.nodeName == "parsererror" ) { throw "parsererror"; }