asp.netajaxcallbackicallbackeventhandler

ICallbackEventHandler request every 1 second


I have code that fires an ICallbackEventHandler every 1000ms. When I run this code locally the data responds quick like every 1 second.

I then uploaded this on the server and sometimes the data responds 1 second and sometimes 3 seconds and then sometimes 6-7 seconds, why is this?

The bit of code that makes this recursive call every 1 second to the server is below:

function MessageServerResponse(param, context) {
    if (param.length > 0) {
        var splitParam = param.split("~");
        var id = splitParam[0];
        var data= splitParam[1];

        $('#' + id).prepend(data);
    }

    setTimeout("MessageServerRequest();", 1000);
}

Solution

  • if u r the only person who use server, the response would be always 1 second. and u cannot expect client to dedicately response your script

    1 of my trick to make it faster