Web APIを使用してデータベースからユーザーを削除する次の関数があります。サーバー側関数は、ユーザーが見つかって削除されたか、ユーザーIDが見つからなかったかを示す文字列を返します。「文字列」タイプを返します。
以下はajax関数です
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
});
問題は、deleteuser() 関数を呼び出すと、返されるアラート応答が常に null になることです。