问题
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