Cannot properly set the Accept HTTP header with jQuery

I also had trouble with this, not just in IE but also in Chrome and Safari using jQuery 1.6.2. This solution appears to work as intended in all browsers I’ve tried (Chrome, Safari, IE, Firefox).

$.ajax({
    headers: { 
        Accept : "text/plain; charset=utf-8",
        "Content-Type": "text/plain; charset=utf-8"
    },
    data: "data",
    success : function(response) {
        ...
    }
})

Try that if this is still giving you trouble.

Leave a Comment