好奇,如果有人知道数据参数的差异.
我有一个$.post方法,它采取$('#myform').serialize()我的数据参数和工作.
如果我使用该$.ajax()方法尝试相同,它不起作用,因为我的数据参数看起来不正确.
有谁知道差异和我可能会使用什么而不是上述.serialize?
我正在尝试使用$ .post方法来调用Web服务,我使用$ .ajax方法工作:
$.ajax({
type: "POST",
url: "StandardBag.aspx/RemoveProductFromStandardBag",
data: "{'standardBagProductId': '" + standardBagProductId.trim() + "' }",
success: function(){
$((".reload")).click();
},
dataType: "json",
contentType: "application/json"
});
Run Code Online (Sandbox Code Playgroud)
但是当我将相同的方法移动到$ .post方法时,它将无法工作:
$.post("StandardBag.aspx/RemoveProductFromStandardBag",
"{'standardBagProductId': '" + standardBagProductId.trim() + "' }",
function () { $((".reload")).click(); },
"json"
);
Run Code Online (Sandbox Code Playgroud)
我错过了什么?