#384 closed bug (worksforme)
IE fails to send/set custom request headers
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | major | Milestone: | 1.1.4 |
Component: | ajax | Version: | 1.1.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
It'd be nice to allow custom request headers in AJAX requests.
Here is a patch:
Index: src/ajax/ajax.js =================================================================== --- src/ajax/ajax.js (revision 569) +++ src/ajax/ajax.js (working copy) @@ -710,6 +710,7 @@ dataType: null, data: null, url: null, + headers: {} }, s); // if data available @@ -746,6 +747,10 @@ // Set header so the called script knows that it's an XMLHttpRequest xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); + + jQuery.each(s.headers, function(i) { + xml.setRequestHeader(i, this); + }); // Make sure the browser sends the right content length if ( xml.overrideMimeType )
Change History (15)
comment:1 Changed 16 years ago by
Component: | ajax |
---|---|
Keywords: | added; ajax headers removed |
Owner: | john deleted |
Priority: | minor |
Summary: | Allow custom request headers in AJAX requests → Allow |
Type: | feature |
comment:2 Changed 16 years ago by
Component: | → ajax |
---|---|
Keywords: | ajax headers added; removed |
Owner: | set to john |
Priority: | → major |
Summary: | Allow → Allow custom request headers |
Type: | → enhancement |
comment:3 Changed 16 years ago by
Milestone: | → 1.1 |
---|---|
Version: | → 1.1 |
comment:4 Changed 16 years ago by
Component: | ajax |
---|---|
Keywords: | added; ajax headers removed |
Milestone: | 1.1 |
Owner: | john deleted |
Priority: | major |
Summary: | Allow custom request headers → Allow |
Type: | enhancement |
Version: | 1.1 |
Nice gusetbook! |
comment:10 Changed 16 years ago by
Component: | → ajax |
---|---|
Keywords: | request removed |
Milestone: | → 1.1 |
Owner: | set to john |
Priority: | → major |
Summary: | Allow → IE fails to send/set custom request headers |
Type: | → bug |
Version: | → 1.1 |
There is now a "preprocess" option for $.ajax that allows to set both custom headers and override mimeTypes. IE (5 - 7) seems to fail to set/send custom headers, therefore I leave this ticket open until a solution or explanation is found for that issue.
comment:11 Changed 16 years ago by
Renamed "preprocess" to "before" for consistency with form plugin.
comment:12 Changed 16 years ago by
The callback is now "beforeSend".
The tests still fail for IE. Using a pseudo-standard header starting with "X-..." doesn't help either.
comment:13 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Seems like this is only a problem in the testsuite, as noone else is reporting this problem.
comment:14 Changed 16 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
I'm currently having the same problem in FF. the 'X-Requested-With' header which should be built-in to jQuery is not being sent with the request. I've checked every line of the code and I'm certain the following lines get executed:
1998 Set header so the called script knows that it's an XMLHttpRequest 1999 xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
I've also tried my own implementation... Add custom header to every call (HTTP_X_METHOD:Ajax) $().ajaxSend(function(a,r,o){ r.setRequestHeader("X-Method", "Ajax"); });
But this also fails...
comment:15 Changed 15 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.1a → 1.1.4 |
need: | → Review |
Resolution: | → worksforme |
Status: | reopened → closed |
Version: | 1.1a → 1.1.3 |
iam we! |