我正在使用返回进度事件的第二方文件下载程序。我可以捕获事件并调用服务器上的程序来执行更新(为了安全起见,我可以告诉最近的活动)。如何在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