Is it possible to append request parameters to a HTTP DELETE request in ajax?

*爱你&永不变心* 提交于 2020-01-05 03:56:16

问题


I'm trying to submit a simple jQuery ajax call but using the DELETE method instead of GET or POST. The method is queried but the parameters don't seem to be passed up - I can see this when I inspect the request URL in firebug. Here's what the code looks like:

$.ajax({
    type:"DELETE",
    url:"/api/deleteGame",
        dataType:"json",
    data: "gameId=" + gameId + "&userId=" + userId,
    success:function(json)
    {
        if(json != null && json.errors == undefined) {  
            alert("Game successfully deleted");
            parent.closeDialog();
            parent.refreshCaller();
        } else {
            showServerErrors(json.errors);
        }
    },
    error:function(xhr, textstatus, errorThrown)
    {
        alert("An error occured! " + errorThrown + ", " + textstatus)
    }
});

Does this look okay? Is it correct to append the parameters to the DELETE request string like you would a GET?

I'm using the latest version of Chrome and FF 5.

Thanks in advance, Gearoid.


回答1:


See $.ajax with DELETE loses parameters.



来源:https://stackoverflow.com/questions/6535340/is-it-possible-to-append-request-parameters-to-a-http-delete-request-in-ajax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!