Bug Tracker

Modify

Ticket #8106 (closed bug: wontfix)

Opened 2 years ago

Last modified 2 years ago

ajaxSetup instantiated contentType not included when no data is sent

Reported by: briana@… Owned by: jaubourg
Priority: blocker Milestone: 1.next
Component: ajax Version: 1.5
Keywords: Cc:
Blocking: Blocked by:

Description

Perhaps this was done purposely, but this is a change to the method.

 http://jsfiddle.net/kdgVJ/1/

Change History

comment:1 Changed 2 years ago by rwaldron

  • Owner set to jaubourg
  • Priority changed from undecided to blocker
  • Status changed from new to assigned
  • Component changed from unfiled to ajax

comment:2 Changed 2 years ago by jitter

I think this is only a little wording problem in the documentation. The  jQuery.ajax() documentation says:

contentType: [...] If you explicitly pass in a content-type to $.ajax() then it'll always be sent to the server (even if no data is sent).

These two test cases show that the documentation has to be taken literal.

 test case works as expected because contentType is passed directly to jQuery.ajax(...)

This  test case doesn't send the content-type header when there is no data as the contentType setting wasn't passed "directly" to jQuery.ajax(...)

So the documentation needs to be taken literal. Only if you pass the contentType option directly to $.ajax(...) it gets send even when there is no data.

comment:3 Changed 2 years ago by briana@…

This is the specific case where I'm having an issue. Maybe this is just an issue with $.post():

 http://jsfiddle.net/G8zgB/

jQuery 1.4.3-1.4.4 will apply the contentType, other versions do not (so maybe this was never meant to happen?)

comment:4 Changed 2 years ago by danheberden

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

Correct - this behaviour was actually a bug in 1.4.2/3. The method to force content-type as jitter explains is the only way.

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.