我正在使用返回進度事件的第二方文件下載程序。我可以捕獲事件並調用服務器上的程序來執行更新(爲了安全起見,我可以告訴最近的活動)。如何在javascript中存儲變量以限制http調用的數量?
我每秒獲得大約30個事件,所有百分比下載1%,然後30%更多2%,然後30%更多3%等。我想限制我的http呼叫每個百分比更改1次%,2%,3%等。我會在頁面上放置一個隱藏字段並對其進行比較並進行更新,但自從下載進行後,我無法刷新頁面。
有沒有在JavaScript或jQuery中使用某種類型的客戶端存儲的方法呢?
換句話說,我需要能夠告訴當從1 PercentCurrent值更改爲2等
我的JavaScript函數如下所示:
function onProgress(PercentTotal, PercentCurrent, Index){
var xmlhttp;
//The handler will update the file progress
if (typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();
}
if (!xmlhttp) {
throw "Browser doesn't support XMLHttpRequest.";
}
var data = "";
xmlhttp.open("POST", "UpdateProgress.aspx?PercentCurrent=" + PercentCurrent, true);
//Send the proper header information along with the request
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//xmlhttp.setRequestHeader("Content-length", data.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(data);
}
謝謝你,吉姆
如何以及在哪裏你把這 – mplungjan 2011-03-26 16:39:57