onSuccess和onFailure;不要被解雇

本文关键字:onFailure onSuccess | 更新日期: 2023-09-27 17:59:01

我在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。我做错了什么?

onSuccess和onFailure;不要被解雇

您的PageMethod看起来像这个

PageMethods.LoginUser(onSuccess, onFailure, email, pass);

当你调用它时,它看起来像这个

PageMethods.LoginUser(email, pass);

参数的顺序应该与方法的顺序相同。

PageMethods.LoginUser(email, pass, onSuccess, onFailure);