gpt4 book ai didi

javascript - onSuccess 和 onFailure 不会被解雇

转载 作者:行者123 更新时间:2023-12-03 09:47:17 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com