Is it a good practice to use setRequestHeader twice like below? I need to use X-Requested-With in order to get some HTML forms.
function formRequest (method, url) {
return new Promise(function (resolve, reject) {
var client = new XMLHttpRequest();
client.open(method, url);
client.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
client.setRequestHeader('Content-Type', 'text/html');
client.onload = function () {
// ...
resolve(client.response);
};
// ...
client.send();
});
}
Thank you.
By the way, it works with or without the Content-type.
jsat Question appears to return expected result?