Bug Tracker

Opened 15 years ago

Closed 15 years ago

#1541 closed bug (wontfix)

[PATCH] Ajax request with dataType 'xml' raises parsererror on HTTP HEAD response

Reported by: gbuesing Owned by:
Priority: major Milestone: 1.2.1
Component: ajax Version: 1.2
Keywords: ajax xml Cc:
Blocked by: Blocking:


The 1.1.4 release adds the following check on the xmlHttpRequest object when dataType is 'xml':

if ( xml && data.documentElement.tagName == "parsererror" )
  throw "parsererror";

This raises an error when malformed xml is sent to the browser, which is desirable behavior, but it also raises an error when the server responds with an HTTP HEAD response (which has a blank body) to indicate success.

This change therefore breaks compatibility with existing apis that use HTTP HEAD responses to indicate success.

I've added logic so that a blank response body can pass through successfully:

if ( xml && r.responseText.match(/\S/) && data.documentElement.tagName == "parsererror" )
  throw "parsererror";

Attachments (1)

xml_parse_error_skipped_when_request_body_is_blank.diff (565 bytes) - added by gbuesing 15 years ago.

Download all attachments as: .zip

Change History (2)

comment:1 Changed 15 years ago by john

Resolution: wontfix
Status: newclosed

That's correct - if there's no response from the server, then there's no way that an XML document can be built - thus throwing an error.

See this thread for more details: http://groups.google.com/group/jquery-dev/browse_frm/thread/ba67ecdec0059cc0/eb87e5bf1f7b989d

Note: See TracTickets for help on using tickets.