从javascript进行PUT / DELETE非ajax服务调用

时间:2017-07-28 17:06:53

标签: javascript jquery ajax web-services

我是javascript的新手,我想进行一次服务调用,从DB中删除一条记录。我能够进行GET / POST调用,但无法从我的脚本中进行DELETE调用。

根据我的要求,我不想进行ajax调用。以下是我的代码段,请建议

$.delete('http://localhost:3000/remove/'+friendName,{},function(response){     
}).error(function(){});

1 个答案:

答案 0 :(得分:0)

jquery中没有$ .delete这样的东西。您需要使用正确的类型

创建$ .ajax请求
$.ajax({
   url: '{url goes here}',
   type: 'DELETE',
   success: function(result) {
       // Do something with the result
   } 
});