0

我正在尝试使用以下代码让 AJAX 到 WCF 工作的这个示例。在FF中查看时,什么都不显示,在IE中查看时,显示时间。
我正在使用 IIS 7,顺便说一句。

    function getTime() {            
        TimeService.TimeService.GetTimeFormatted("dd-mm-yyyy [hh:mm:ss]", onMethodCompleted, onMethodFailed);
    }

    function onMethodCompleted(results) {
        $get("currentTimeLabel").innerText = results;        
    } 

...


4

1 回答 1

2

我没有使用过 MS AJAX,但据我所知,

function getTime() {            
    TimeService.TimeService.GetTimeFormatted("dd-mm-yyyy [hh:mm:ss]", onMethodCompleted, onMethodFailed);
}

那里似乎会在 GetTimeFormatted 上运行 aync 调用,并将结果传递给“onMethodCompleted”..

function onMethodCompleted(results) {
    $get("currentTimeLabel").innerText = getTime();        
}

每次调用它时,都会重新调用 getTime 方法。所以你正在做的是开始一个异步调用循环。

在我看来(注意到我没有使用过 ms ajax ..)你可能应该有更多类似的东西。

function getTime()
{      
    var onComplete = function(results) { $get("currentTimeLabel").innerText = results; }
    TimeService.TimeService.GetTimeFormatted("dd-mm-yyyy [hh:mm:ss]", onComplete , onMethodFailed);
}

然后在您希望更新结果时调用 getTime 方法。

于 2008-10-31T13:11:27.710 回答