我有以下jQuery代码来调用一个aspx页面中的WebMethod:
如何更改客户端代码以成功调用这个新的方法签名?
编辑:
以下两种语法都有效。
并且。
我有以下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
});
这是Web方法的签名:
[WebMethod]
public static string GetJewellerAssets(int jewellerId)
{
这个很好用。
但是现在我需要将两个参数传递给Web方法。
新的Web方法看起来像这样:
[WebMethod]
public static string GetJewellerAssets(int jewellerId, string locale)
{
}
如何更改客户端代码以成功调用这个新的方法签名?
编辑:
以下两种语法都有效。
data: '{ "jewellerId":' + filter + ', "locale":"en" }',
并且。
data: JSON.stringify({ jewellerId: filter, locale: locale }),
其中filter和locale是本地变量
JSON.stringify
与一个对象字面量一起使用时,你必须在大括号内包含参数名称和冒号。使用JSON.stringify(objectLiteral)
是不起作用的。 - Kaleb Anderson[WebMethod] [ScriptMethod(UseHttpGet = true)] public static string TestIBAN(string ccc)
吗? - Kiquenet