I make a request with Ajax and the request works fine when I use GET. It doesn’t if I use POST in my script and my Rest-Service.
$.ajax({
type: 'POST',
url: 'http://localhost/WebRestService/rest/User/deletePC',
dataType: "text",
success: function(antwort){
alert("response:"+antwort);
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(antwort,"text/xml");
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(antwort);
}
},
error:function(x,e){
if(x.status==0){
alert('You are offline!!\n Please Check Your Network.');
}else if(x.status==404){
alert('Requested URL not found.');
}else if(x.status==500){
alert('Internel Server Error.');
}else if(e=='parsererror'){
alert('Error.\nParsing JSON Request failed.');
}else if(e=='timeout'){
alert('Request Time out.');
}else {
alert('Unknow Error.\n'+x.responseText);
}
}
});
If I use POST I get an unknown error. What is the problem?
THX!
Edit: DELETE and PUt also doesn’t work.
Edit2: if I use firefox Poster it works fine.
My where is you data that you are sending in your ajax request?
When you send post request you have to identify your data that you are sending.
You are missing
dataattribute of post request.For further reading consult here