我想在我的ASP.net项目上实现实时更新,所以我试图实现长轮询机制和Comet。
var isPolling = 0;
function longPolling()
{
isPolling++;
$.ajax({
type: "GET",
url: "CometAsyncHandler.ashx?waitTime=60", // one minute
//async: true,
cache: false,
//timeout:12000,
success: function(data){
isPolling--;
if(data == "NEWDATAISAVAILABLE")
RefreshData(); // this function is generated by using RegisterFunctionToPostBack()
else if( data == "TOOLONG-DOITAGAIN" )
setTimeout("longPolling()", 0 );
else
addLongPollingError("error", "Error on server side. Received data: \"" + data + "\"");
},
error: function(XMLHttpRequest, textStatus, errorThrown){
isPolling--;
addLongPollingError("error", textStatus + " (" + errorThrown + ")");
}
});
}
$(document).ready(function(){
longPolling(); // Start the initial request
});
我已经使用SqlDependency类为MS SQL数据库成功完成了它,但它可以工作但是如何使用MySQL DB来实现这一点。