AJAX到WCF不能在FireFox中工作

时间:2022-12-06 18:02:17

I'm trying to get this sample for AJAX to WCF working, with the following code. When viewed in FF, nothing is displayed, and when viewed in IE, the time is displayed.
I'm using IIS 7, btw.

我正在尝试使用以下代码将此样本用于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;        
    } 

...


1 个解决方案

#1


2  

I've not used MS AJAX, but as far as I can tell,

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

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

That right there seems like it'll run an aync invoke on GetTimeFormatted, and pass the results on to "onMethodCompleted"..

似乎它会在GetTimeFormatted上运行异步调用,并将结果传递给“onMethodCompleted”。

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

Will, for every time it gets invoked, re-invoke the getTime method.. So what you're doing is starting a loop of asynchronous invokes.

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

It seems to me (noted that I've not used ms ajax..) that you should probably have something more like..

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

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

And then invoke the getTime method when you want the results updated.

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

#1


2  

I've not used MS AJAX, but as far as I can tell,

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

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

That right there seems like it'll run an aync invoke on GetTimeFormatted, and pass the results on to "onMethodCompleted"..

似乎它会在GetTimeFormatted上运行异步调用,并将结果传递给“onMethodCompleted”。

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

Will, for every time it gets invoked, re-invoke the getTime method.. So what you're doing is starting a loop of asynchronous invokes.

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

It seems to me (noted that I've not used ms ajax..) that you should probably have something more like..

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

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

And then invoke the getTime method when you want the results updated.

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