我有以下jQuery代码在aspx页面中调用webmethod
$.ajax({
type: "POST",
url: "popup.aspx/GetJewellerAssets",
contentType: "application/json; charset=utf-8",
data: '{"jewellerId":' + filter + '}',
dataType: "json",
success: AjaxSucceeded,
error: AjaxFailed
});
这是网络方法签名
[WebMethod]
public static string GetJewellerAssets(int jewellerId)
{
这很好。
但是现在我需要将两个参数传递给Web方法
新的网络方法如下所示
[WebMethod]
public static string GetJewellerAssets(int jewellerId, string locale)
{
}
如何更改客户端代码以成功调用此新方法签名?
编辑:
以下2种语法有效
data: '{ "jewellerId":' + filter + ', "locale":"en" }',
和
data: JSON.stringify({ jewellerId: filter, locale: locale }),
其中filter和locale是局部变量