views:

439

answers:

1

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.

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

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

...


+1  A: 

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

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"..

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.

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

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.

Sciolist
Thanks! I should have picked up the cascade when I opened the FireBug console to look at another error.
ProfK
Now it's working in IE but not FF. Changed the subject line of the question.
ProfK

related questions