Set AJAX content type header in request from IE
Just pass the content-type as one of your parameters to the .ajax
method:
var retval = jQuery.ajax({ type:'post', url: url, contentType: 'application/json', data: JSON.stringify(data)});
Yes, you could use the contentType
parameter:
$.ajax({ url: '/someurl', type: 'POST', contentType: 'application/json', data: JSON.stringify({ foo: 'bar' }), success: function(result) { }});
Request sent:
POST /someurl HTTP/1.1Host: example.comContent-Length: 13X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.83 Safari/535.11Content-Type: application/jsonAccept: */*Accept-Encoding: gzip,deflate,sdchAccept-Language: en-US,en;q=0.8Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3{"foo":"bar"}