gpt4 book ai didi

javascript - PageMethods 实际上返回什么?

转载 作者:行者123 更新时间:2023-12-02 19:18:42 25 4
gpt4 key购买 nike

此代码从后面的代码中的公共(public)静态字符串获取返回值,并显示警报中返回的内容。

<script type="text/javascript"> 
function GetFromServer()
{
PageMethods.GetHello(OnGetHelloComplete);
}
function OnGetHelloComplete(result, userContext, methodName)
{
alert("Result: " + result + "\n" +
"Context: " + userContext + "\n" +
"Method name: " + methodName);
}
</script>

后面代码中的Web方法是一个公共(public)静态字符串。但它返回了什么?

为什么我不能写...

var myString = PageMethods.GetHello()

“result”、“userContext”和“methodName”从哪里出现?

编辑:请忽略,我查看了源代码并看到了那里正在输出的内容。

最佳答案

GetHello 调用对服务器的调用,OnGetHelloComplete 是在请求​​完成且填充参数时执行的回调。

关于javascript - PageMethods 实际上返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12796361/

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