X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=ajax%2Fajax.js;h=af80810e36b7bdabe3ddef7759288e642171e56a;hb=1edf3a2be937a1d0f087ac06e2f57e2c60ef25ea;hp=5d6126af293db7f03d85e578be64d6bc9ed7cc1f;hpb=2d9979c73fad6f9aa6e78054dedb0e4aa78ec551;p=jquery.git diff --git a/ajax/ajax.js b/ajax/ajax.js index 5d6126a..af80810 100644 --- a/ajax/ajax.js +++ b/ajax/ajax.js @@ -170,15 +170,18 @@ jQuery.ajax.active = 0; // Determines if an XMLHttpRequest was successful or not jQuery.httpSuccess = function(r) { - return ( r.status && ( r.status >= 200 && r.status < 300 ) || - r.status == 304 ) || !r.status && location.protocol == "file:"; + return r.status ? + ( r.status >= 200 && r.status < 300 ) || r.status == 304 : + location.protocol == "file:"; }; -// Get the data out of an XMLHttpRequest +// Get the data out of an XMLHttpRequest. +// Return parsed XML if content-type header is "xml" and type is "xml" or omitted, +// otherwise return plain text. jQuery.httpData = function(r,type) { - // Check the headers, or watch for a force override - return r.getResponseHeader("content-type").indexOf("xml") > 0 || - type == "xml" ? r.responseXML : r.responseText; + var ct = r.getResponseHeader("content-type"); + var xml = ( !type || type == "xml" ) && ct && ct.indexOf("xml") >= 0; + return xml ? r.responseXML : r.responseText; }; // Serialize an array of form elements or a set of