它不起作用,因为在您的
$.post方法中,您无法将请求的内容类型设置为
application/json。因此,不可能使用调用ASP.NET
PageMethod,
$.post因为ASP.NET PageMethod需要JSON请求。您将不得不使用
$.ajax。
我将只修改
data,以确保它已正确进行JSON编码:
$.ajax({ type: "POST", url: "StandardBag.aspx/RemoveProductFromStandardBag", data: JSON.stringify({ standardBagProductId: standardBagProductId.trim() }), success: function() { $(".reload").click(); }, dataType: "json", contentType: "application/json"});


