无法使用REST api的删除动词删除记录

时间:2016-03-11 05:00:57

标签: rest azure-web-sites

我试图在按钮点击时从下拉列表中删除记录。当我检查时,我看到了这些错误:

  

无法加载资源:服务器响应状态为405   (方法不允许)dropdown.html:1 XMLHttpRequest无法加载   http://toyauction.azurewebsites.net/api/toys/19。回应   预检具有无效的HTTP状态代码405

我知道该功能正在拾取需要删除的玩具的正确ID。

我的代码:

$('#deleteToy').click(function(){
               $.ajax({
                    url: baseURI + "toys/" + toydropdown.val(),
                    method: "DELETE",
                   dataType: "json",
                    data: {},

                       error: function (xhr, textStatus, errorThrown) {
                       alert("An error occurred!!");
               }

                }).done(function (result) {
                    // display a message that the toy is deleted
                    $('<p></p>').html(result.Name + ' toy deleted!').prependTo('section#toy');
                    // TODO: refresh the toy dropdown list
                    getToys(toysdropdown);

                });

                });

0 个答案:

没有答案
相关问题