Bug Tracker

Modify

Ticket #1541 (closed bug: wontfix)

Opened 6 years ago

Last modified 6 years ago

[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:
Blocking: Blocked by:

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 6 years ago by gbuesing

comment:1 Changed 6 years 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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.