aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-07-21 00:52:30 +0000
committerJohn Resig <jeresig@gmail.com>2007-07-21 00:52:30 +0000
commite20e8e6e3cc565469cedfad105565ce534c98c71 (patch)
treee17626f3cb5bd31e2711939f46b712797ed28dde
parent37407164803df62c4efb1332e7f94b56e693a108 (diff)
downloadjquery-e20e8e6e3cc565469cedfad105565ce534c98c71.tar.gz
jquery-e20e8e6e3cc565469cedfad105565ce534c98c71.zip
Added support for parsererror errors from Ajax requests (bug #1145).
-rw-r--r--src/ajax/ajax.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index 4b1e9b0e2..7d83a0eb6 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -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" )