X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=645caf72e4ad2c4fa90145cf08267184ec2c6f18;hb=80a149b82831defa1a9f724801daefda0a8c5685;hp=fa047188aed2befd0b164cc82fa713c3110e2842;hpb=c47f6f8f523c8add478fbf5570a67015426f5b86;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index fa04718..645caf7 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -77,7 +77,7 @@ jQuery.fn.extend({ complete: function(res, status){ // If successful, inject the HTML into all the matched elements if ( status == "success" || !ifModified && status == "notmodified" ) - self.html(res.responseText) + self.html(res.responseText); self.each( callback, [res.responseText, status, res] ); } @@ -622,7 +622,7 @@ jQuery.extend({ // Wait for a response to come back var onreadystatechange = function(isTimeout){ // The transfer is complete and the data is available, or the request timed out - if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) { + if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) { requestDone = true; // clear poll interval @@ -662,7 +662,7 @@ jQuery.extend({ } else jQuery.handleError(s, xml, status); } catch(e) { - status = "error"; + status = "parsererror"; jQuery.handleError(s, xml, status, e); } @@ -757,8 +757,11 @@ jQuery.extend({ */ httpData: function( r, type ) { var ct = r.getResponseHeader("content-type"); - var data = !type && ct && ct.indexOf("xml") >= 0; - data = type == "xml" || data ? r.responseXML : r.responseText; + var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0; + data = xml ? r.responseXML : r.responseText; + + if ( xml && data.documentElement.tagName == "parsererror" ) + throw "parsererror"; // If the type is "script", eval it in global context if ( type == "script" )