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,开发者_C百科 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);
}
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
- if u use normal <form> postback put as less as u can in form. more html in form means more data transfer
- if u use updatepanel just keep it small or make dedicate update panel to boost performance
- for jquery, i'd suggest $.ajax({cache:true})
精彩评论