X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax.js;h=a41de4cdc46d3554a9acf321c34b32cee1d8a490;hb=ec7fdf37235583a807b3f08e146edaadc81ca974;hp=2365387dca9efb11758471d4ce08f7ffc4fd5a39;hpb=28ab4d32247943e1ae3409b23fe69303df0bc9eb;p=jquery.git diff --git a/src/ajax.js b/src/ajax.js index 2365387..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 @@ -455,7 +455,8 @@ jQuery.extend({ try { // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 return !xhr.status && location.protocol == "file:" || - ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; + // Opera returns 0 when status is 304 + ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 || xhr.status == 0; } catch(e){} return false; }, @@ -471,7 +472,8 @@ jQuery.extend({ if (etag) jQuery.etag[url] = etag; - return xhr.status == 304; + // Opera returns 0 when status is 304 + return xhr.status == 304 || xhr.status == 0; }, httpData: function( xhr, type, s ) { @@ -479,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"; }