How to set the content type of an XDomainRequest object?

for XMLHttpRequest it is quite simple:

var xhr = new XMLHttpRequest();
xhr.open('POST', MyUrl, true);
xhr.setRequestHeader('Content-Type', 'application/json')

But how do I achieve this for XDomainRequest?

+5
source share
1 answer

Cannot override XMLHttpRequest content type. You must correctly install it on the server, for example. for php:

header('Content-type: application/json');

If this is not possible, you can create a local proxy script that reflects your crossdomain script with the correct header

0
source

All Articles