Bug Tracker

Ticket #1541 (closed bug: wontfix)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: gbuesing Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.1 Component: ajax
Version: 1.2 Keywords: ajax xml
Cc: Needs: Review

Description

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

Change History

Changed 1 year ago by gbuesing

Changed 1 year ago by john

  • status changed from new to closed
  • version changed from 1.1.4 to 1.2
  • resolution set to wontfix
  • milestone changed from 1.2 to 1.2.1

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.