Tabby Laredo
Tabby Laredo

Reputation: 177

jQuery .ajax PUT request not respecting custom header

I'm losing my custom header when using PUT type with .ajax. But, the header is fine with GET, but gets mangled with PUT. Please see evidence 1:

// GOOD GET:

$.ajax({
    url: url,
    type: 'GET',
    dataType: 'json',
    headers: {
        Accept: "application/json"
    }
});

// Actual header sent (using fiddler):
Accept: application/json

// BAD PUT:

$.ajax({
    url: url,
    type: 'PUT',
    dataType: 'json',
    headers: {
        Accept: "application/json"
    }
});

// Actual header sent (using fiddler):
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

As you can see the only difference is the value of type causing the value of the Accept part of the header gets trashed. jquery-1.8.2.js. Any thoughts? Thanks

Stabby

Upvotes: 2

Views: 664

Answers (1)

zb'
zb'

Reputation: 8059

It seems it is browser related:

http://jsfiddle.net/oceog/WqXzA/

Request URL:http://fiddle.jshell.net/_display/
Request Method:PUT
Status Code:200 OK
Request Headersview source
Accept:application/json

Chrome 25.0

Upvotes: 1

Related Questions