Skip to main content

Bug Tracker

Side navigation

#8106 closed bug (wontfix)

Opened January 31, 2011 10:43PM UTC

Closed February 01, 2011 07:49AM UTC

ajaxSetup instantiated contentType not included when no data is sent

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

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

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

Attachments (0)
Change History (4)

Changed January 31, 2011 10:57PM UTC by rwaldron comment:1

component: unfiledajax
owner: → jaubourg
priority: undecidedblocker
status: newassigned

Changed February 01, 2011 12:01AM UTC by jitter comment:2

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.

Changed February 01, 2011 12:26AM UTC by briana@coilcraft.com comment:3

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?)

Changed February 01, 2011 07:49AM UTC by danheberden comment:4

resolution: → wontfix
status: assignedclosed

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.