我在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。我究竟做错了什么?
最佳答案
您的PageMethod看起来像这样PageMethods.LoginUser(onSuccess, onFailure, email, pass);
当您调用它时,它看起来像这样
PageMethods.LoginUser(email, pass);
您的参数应与方法的顺序相同。
PageMethods.LoginUser(email, pass, onSuccess, onFailure);
关于javascript - onSuccess和onFailure不会被解雇,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30981451/