【发布时间】:2016-08-19 21:58:24
【问题描述】:
我有一个返回boolean 的WebService's 方法:
[WebMethod(EnableSession = true), ScriptMethod(UseHttpGet = true)]
public bool StartMonitoring()
{
return Schedule.StartMonitoring();
}
这是 Schedule 类的方法:
public static bool StartMonitoring()
{
return true;
}
这是JavaScript's服务电话:
var success = false;
success = myself.get_Service().StartMonitoring();
alert(success);
当弹出窗口显示时,它显示"undefined" 而不是true
我错过了什么?
【问题讨论】:
-
myself指的是什么? -
如果你像这样直接从
StartMonitoring返回true会发生什么:public bool StartMonitoring(){ return true; }- 只是看看你是否真的得到了任何价值。 -
我假设 get__Service 或 StartMonitoring 是您所说的服务。由于服务是异步调用,因此您不能期望成功。尝试使用异步方法,如回调。
标签: javascript asp.net web-services