我在PageMethod调用中使用了onSuccess和onFailure。然而,它们都没有被调用,WebMethod也没有被解雇。
alert("1");
PageMethods.LoginUser(onSuccess, onFailure, email, pass);
alert("2");
function onSuccess(val)
{
}
function onFailure()
{
}
[WebMethod(EnableSession = true)]
public static int LoginUser(string email, string pass)
{
//Doesn't get fired
}
当我删除它们并仅将值发送到WebMethod时,它可以工作:
PageMethods.LoginUser(email, pass);
//This fires the Web Method
我也在我的ScriptManager中启用了PageMethods。我做错了什么?
答案 0 :(得分:1)
你PageMethod看起来像这样
PageMethods.LoginUser(onSuccess, onFailure, email, pass);
当你打电话时,它看起来像这样
PageMethods.LoginUser(email, pass);
您的参数应与方法的顺序相同。
PageMethods.LoginUser(email, pass, onSuccess, onFailure);