0

I have the following function that deletes a user from my database using a Web API the server side function returns a string to show whether the user was found and deleted or the user id was not found, it returns a "string" type,

following is the ajax function

function deleteuser() {

        var id = $('#<%=txtDelete.ClientID %>').val();
        $.ajax({
            url: "<%=Page.ResolveUrl("/api/User/")%>" + id,
            type: "DELETE",
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (response) {
                alert(response);
                getAllContacts();
            },

            error: function (x, e) {
                alert(x.responseText);
                alert(e.toString());
                alert('fail');
                getAllContacts();

            }, async: true
        });

the problem is that when I call the deleteuser() function, the alerted response returned is always null

4

2 回答 2

0

要发出的请求类型(“POST”或“GET”),默认为“GET”。注意:这里也可以使用其他 HTTP 请求方法,例如 PUT 和 DELETE,但并非所有浏览器都支持。

于 2013-11-11T09:09:46.780 回答
0

推荐使用 POST http 方式,并非所有浏览器都支持 DELETE。

于 2013-11-11T09:27:00.803 回答