在我的客户端应用程序 - 用javascript和jQuery编写 - 我有一个函数,我正在使用DELETE方法向我的服务器执行$ .ajax请求.
代码是这样的:
this.delete_one = function(id){
console.log(id);
$.ajax({
url: sitesCtrl.url,
type: "delete",
dataType: 'json',
data: {"id": id},
success: function(data){
if (data.success){
$("sitesList").remove("#" + id + "\"");
}
else{
console.log(data.message);
}
},
error: function(){
console.log("internal error");
}
})
};
Run Code Online (Sandbox Code Playgroud)
问题是服务器获取没有参数"id"的请求!只是一个简单的DELETE(根据firebug).通过PUT,POST或GET它可以很好地工作.