Bug Tracker

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#4453 closed bug (worksforme)

Ajax issues on Safari 3

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

Description

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:

jQuery.ajax({

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

xhr.setRequestHeader("Content-Type","application/json");

}, 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 (2)

comment:1 Changed 6 years ago by dmethvin

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

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

#1118 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.