How do I add an accept header 'text/xml' in JQuery ajax file upload? It will upload a PDF file.
Here is the code I am using:
var fd = new FormData(document.getElementById('file'));
$.ajax({
url: '/myurlhere',
type: 'POST',
data: fd,
cache: false,
contentType: false,
processData: false,
success: function(response) {
console.log('success... '+response);
}
}).fail(function(xhr,status,error) {
console.log(error);
});
The server expects the accept header to be xml, so causes a 406 error. I have tried using dataType: 'xml' or header { Accept: 'text/xml' } and it causes a 400 error.