Can anyone tell me what I am doing wrong in the below code. I want to Ajax an xml (either text/xml or application/xml) into my REST service (same app server).
When doing that I am getting error code 400 Bad Request.
$.ajax({ type: 'POST',
url: '<url>',
data: '<?xml version="1.0" encoding="UTF-8"?><test>Hello World</test>',
contentType: 'text/xml',
dataType: 'xml',
processData: false,
cache: false,
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status +' '+thrownError);
},
success: function(xml) {
alert('it works: '+xml);
}
});
Any help would be much appreciated.
A 400 error doesn’t occur via Javascript, it occurs on the server. You should specify what server side technology you are using and post the relevant code. Robert Fricke’s answer might shed some light on the server side issue.