From 05a4b784e892ea0dd56201fa1b7a77c7a453bfa7 Mon Sep 17 00:00:00 2001 From: Michael Geary Date: Sun, 2 Jul 2006 02:11:37 +0000 Subject: [PATCH] Fix jQuery.httpData to allow forcing of text data --- ajax/ajax.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ajax/ajax.js b/ajax/ajax.js index 5d6126a..632ed86 100644 --- a/ajax/ajax.js +++ b/ajax/ajax.js @@ -174,11 +174,13 @@ jQuery.httpSuccess = function(r) { r.status == 304 ) || !r.status && 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 xml = ( !type || type == "xml" ) && + r.getResponseHeader("content-type").indexOf("xml") >= 0; + return xml ? r.responseXML : r.responseText; }; // Serialize an array of form elements or a set of -- 1.7.10.4