From 1edf3a2be937a1d0f087ac06e2f57e2c60ef25ea Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 4 Jul 2006 00:42:57 +0000 Subject: [PATCH] Added in a couple AJAX fixes for status and content-type. --- ajax/ajax.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ajax/ajax.js b/ajax/ajax.js index 632ed86..af80810 100644 --- a/ajax/ajax.js +++ b/ajax/ajax.js @@ -170,16 +170,17 @@ 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. // Return parsed XML if content-type header is "xml" and type is "xml" or omitted, // otherwise return plain text. jQuery.httpData = function(r,type) { - var xml = ( !type || type == "xml" ) && - r.getResponseHeader("content-type").indexOf("xml") >= 0; + var ct = r.getResponseHeader("content-type"); + var xml = ( !type || type == "xml" ) && ct && ct.indexOf("xml") >= 0; return xml ? r.responseXML : r.responseText; }; -- 1.7.10.4