Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#7424 closed bug (worksforme)

setRequestHeader IE

Reported by: uthomas Owned by:
Priority: low Milestone: 1.5
Component: ajax Version: 1.4.3
Keywords: Cc:
Blocked by: Blocking:

Description

Hi there again.

I'm afraid last time my ticket was handled as spam... I'm trying to add a custom header to each dynamic HTTP Request and it seems working fine in FF, Safari, Chrome, and Opera but not under IE 8 (build: 8.0.7600.16385).

Morover I can't see either the "x-requested-with" header in IE.

Here is my code:

    $.ajaxSetup({
        beforeSend : function(xhr) {
                xhr.setRequestHeader("custom-header", "custom-value");
        }
    });



    $('#button').click(function() {
        $.ajax({
            url   :   '/valid-url',
            success: function(data){
                alert(data);
            }
        });
    });

Best regards: U. Tamás

Change History (6)

comment:1 Changed 9 years ago by uthomas

Hi,

At least "X-Requested-With" works in IE too, but I had to add:

            type    :   'POST',
            data    :   '',

to the the parameter-list of $.ajax call. :) So my code looks like this now:

    $('#button').click(function() {
        $.ajax({
            type    :   'POST',
            data    :   '',
            url     :   '/a-valid-url',
            success :   function(data){
                alert(data);
            },
            error   :   function(data) {
                alert(data);
            }
        });
    });

comment:2 Changed 9 years ago by uthomas

:)

With the added two lines the "custom-header" has been sent in IE as well... :S I find it weird that without explicitly telling the request-method (POST|GET) the request header doesn't contain the "custom-header" in IE, but it works in other browsers. :)

Best regards: U. Tamás

P.S.: jQuery is great! Just keep go on!

comment:3 Changed 9 years ago by Rick Waldron

Resolution: worksforme
Status: newclosed

comment:4 Changed 9 years ago by jitter

Component: unfiledajax
Priority: undecidedlow

comment:6 Changed 8 years ago by anonymous

setRequestHeader() does not work at all. How can it be a low priority?

Note: See TracTickets for help on using tickets.