Ajax可以工作,但是POST不能工作
我使用Ajax发出请求,当我使用GET时,请求工作正常。如果我在我的脚本和Rest服务中使用POST,则不会发生这种情况Ajax可以工作,但是POST不能工作,ajax,jquery,Ajax,Jquery,我使用Ajax发出请求,当我使用GET时,请求工作正常。如果我在我的脚本和Rest服务中使用POST,则不会发生这种情况 $.ajax({ type: 'POST', url: 'http://localhost/WebRestService/rest/User/deletePC', dataType: "text", success: function(antwort){ alert("response:"+antwort); i
$.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);
}
}
});
如果我使用POST,我会得到一个未知错误。有什么问题
谢谢
编辑:删除和放置也不起作用。
Edit2:如果我使用firefox Poster,效果很好。我的ajax请求中发送的数据在哪里? 当您发送post请求时,您必须识别您正在发送的数据。 您缺少post请求的
数据属性
$.ajax({
type: 'POST',
url: 'http://localhost/WebRestService/rest/User/deletePC',
data:'some data',
dataType: "text",
success: function(antwort){
alert("response:"+antwort);
},
});
为了进一步阅读,请查阅几年后,这一点很清楚,我用POST删除了尸体……真为我的容格感到羞耻;)