Side navigation
#1623 closed bug (worksforme)
Opened September 15, 2007 05:58PM UTC
Closed December 04, 2007 06:47PM UTC
$.ajax not sending X-Requested-With with dataType script
Reported by: | jeremydurham | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.2.2 |
Component: | core | Version: | 1.2 |
Keywords: | xhr x-requested-with ajax | Cc: | |
Blocked by: | Blocking: |
Description
I'm attempting to call the following code with jQuery 1.2:
$.ajax({async:true, dataType:'script', type:'POST', url:'/foo/bar'}); return false;
With jQuery 1.1.x, I was getting back an X-Requested-With of XMLHttpRequest; with jQuery 1.2 I do not get the X-Requested-With back. It seems to be because jQuery 1.2 injects a script tag into the header of the page, whereas jQuery 1.1.4 does not.
Ruby on Rails checks that the X-Requested-With header is set to determine if this is an XML Http request.
Attachments (2)
Change History (1)
Changed December 04, 2007 06:47PM UTC by comment:1
milestone: | 1.2.1 → 1.2.2 |
---|---|
resolution: | → worksforme |
status: | new → closed |
This may or may not have been a problem in 1.2, but when tested in 1.2.1 it works as expected. Using the above test case with FireBug, I found the X-Requested-With was set
If it is a cross domain script load (i.e. the url starts with "http") then yes, that will not be set since XMLHttpRequest won't be used but rather the script is inserted in the head element.