<html>
<head>
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>
<script src="<%=request.getContextPath()%>/boss/common/jquery-1.2.6.js"></script>
<script type="text/javascript">
<!--
var totalData="12345678901234567890abcdefghi";
var curIndex=0;
var totalLeng=totalData.length;
var dealLeng=3;
$(document).ready(function(){
$("#a").load(function(){//IFRAME加载完毕后回调该方法
doTransfer();
});
});
function doTransfer(){
if(curIndex==-1){
return;
}else{
if(curIndex>=totalLeng){
//处理完毕,返回
a.location="http://localhost:8080/com/boss/common/t.jsp?data=-1";
curIndex=-1;
}else{
//处理curIndex=>totalLeng
a.location="http://localhost:8080/com/boss/common/t.jsp?data="+totalData.substring(curIndex,curIndex+dealLeng);
curIndex+=dealLeng;
}
}
}
//-->
</script>
</head>
<body onload="doTransfer()">
<iframe id="a"></iframe>
</body>
</html>
本文介绍了一个利用JavaScript实现的IFRAME加载完成后触发数据分段传输的方法。通过对字符串进行分段处理并使用iframe进行数据传输,实现了数据的有效发送。文中详细解释了如何设置数据传输的间隔及如何在传输完成后返回处理结果。
909

被折叠的 条评论
为什么被折叠?



