Bug Tracker

Ticket #5764 (closed bug: wontfix)

Opened 5 years ago

Last modified 4 years ago

AJAX requests for XML documents fail if the Content-Type is incorrect

Reported by: bgreenlee Owned by:
Priority: minor Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: ajax xml content-type Cc:
Blocking: Blocked by:

Description

If an XML document is sent with the wrong Content-Type (e.g. "text/html"), jQuery will return a parsererror, even if the response body is valid XML. This issue was discovered via a Rails bug in which cached content (in our case, an XML document) is returned with a Content-Type of "text/html" rather than the original Content-Type. See  https://rails.lighthouseapp.com/projects/8994/tickets/1585-action-caching-sets-wrong-content-type-when-cache_path-is-a-string

I have a patch at  http://github.com/bgreenlee/jquery/commit/47eaedf87385dd66421ef9126fddc2aaa0303148

Change History

comment:1 Changed 5 years ago by bgreenlee

comment:2 Changed 4 years ago by snover

  • Status changed from new to closed
  • Resolution set to wontfix

Thanks for the report, but this is not a jQuery bug. If the server is failing to provide the proper Content-Type header for XML data as required by the XMLHttpRequest spec, it is not jQuery’s responsibility to try to process the input anyway.

Note: See TracTickets for help on using tickets.