Bug Tracker

Ticket #4453 (closed bug: worksforme)

Opened 6 years ago

Last modified 5 years ago

Ajax issues on Safari 3

Reported by: kwhinnery Owned by:
Priority: major Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:


When you use headers to set the "Content-Type" header for a request, this breaks in Safari. jQuery parses the dataType parameter and sets the "Content-Type" header once, which usually is fine, but if I try and manually set "Content-Type" header in the beforeSend method, Safari combines the default with the header I set:


url: 'foos.json', data: myJsonString, beforeSend: function(xhr) {


}, success: function(data) {

do something



In Safari, because jQuery defaults "Content-Type" to "application/x-www-form-urlencoded", the text of the "Content-Type" header is set to

"Content-Type": "application/x-www-form-urlencoded, application/json"

Which obviously does not work. Really Safari should just overwrite the header's content when it is reset, but it does not. The workaround is of course to just use the contentType parameter to $.ajax, but I should technically be able to set the header and have the same behavior.

Change History

comment:1 Changed 5 years ago by dmethvin

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

Since there is a documented way to set the Content-Type, it seems like a second way is not needed. There is already an enhancement ticket open for more general header handling in #1118 and this might be addressed if that ticket is tackled.

comment:2 Changed 5 years ago by rwaldron

#1118 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.