function download()
{
xmlHttpRequestDown =CreateXMLHttp();
if (!xmlHttpRequest)
{
alert("XMLHttpRequest创建失败!");
return;
}
var url="download.aspx?ran="+Math.random() ;
xmlHttpRequestDown.open("GET",url,true );
xmlHttpRequestDown.onreadystatechange = CallBackD;
//xmlHttpRequest.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
xmlHttpRequestDown.send(null);
} function Progress()
{
xmlHttpRequest =CreateXMLHttp();
if (!xmlHttpRequest)
{
alert("XMLHttpRequest创建失败!");
return;
}
var url="ajax.aspx?num="+Math.random();
xmlHttpRequest.open("POST",url,true);
xmlHttpRequest.onreadystatechange = CallBack;
//xmlHttpRequest.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
xmlHttpRequest.send(null);
}
如上我new了2个xmlHttpRequest实例,一个下载,一个显示进度条,但是,只能看到进度条一头一尾。
download处理阻塞了progress处理?
为什么会这样?
怎么解决呢,求助
{
xmlHttpRequestDown =CreateXMLHttp();
if (!xmlHttpRequest)
{
alert("XMLHttpRequest创建失败!");
return;
}
var url="download.aspx?ran="+Math.random() ;
xmlHttpRequestDown.open("GET",url,true );
xmlHttpRequestDown.onreadystatechange = CallBackD;
//xmlHttpRequest.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
xmlHttpRequestDown.send(null);
} function Progress()
{
xmlHttpRequest =CreateXMLHttp();
if (!xmlHttpRequest)
{
alert("XMLHttpRequest创建失败!");
return;
}
var url="ajax.aspx?num="+Math.random();
xmlHttpRequest.open("POST",url,true);
xmlHttpRequest.onreadystatechange = CallBack;
//xmlHttpRequest.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
xmlHttpRequest.send(null);
}
如上我new了2个xmlHttpRequest实例,一个下载,一个显示进度条,但是,只能看到进度条一头一尾。
download处理阻塞了progress处理?
为什么会这样?
怎么解决呢,求助
解决方案 »
- 菜鸟提问 ‘i’为空或不是对象 哪错了,求大神
- 强烈推荐大家看“javascript面向对象技术”
- 请教一个问题~~ 望高手回答~~~~~~~
- 有个问题请教一下,就是163打开首页的时候出现的那个flash广告是怎么做的啊?
- 关于JSP和JAVA SCRIPT的通信问题(在线等)
- 如何做到,当用户在文本框内修改一个字符之后,马上触发一个函数?
- 目测:目前的最好的Web开发是什么啊
- 还是showModelessDialog的问题
- iframe中的一个复选框如何表示
- HTML(asp.net)DIV刷新-JQUERY 代码
- 求一个按钮解决文件上传的代码或好用的插件
- 初学JAVASCRIPT,什么工具能有断点调试??
javascript引擎也必须处理完当前任务,才能执行下一个任务,
哪怕是用框架集再打开一个页面执行javascript,其实都是排到一个队列里等待javascript引擎来处理我的理解不知道对不对,大大们给点指示,谢谢
<script>
--I'm script 1--
<script>
当script1执行的时候,其他是不响应的,譬如timer,event。当一个event执行的时候,道理也一样,其他的timer,event也是不响应的。至于ajax能不能多个同步执行:
答案是可以的。只要open指定是异步就ok了。
而你看到的现象应该从网络情况去分析,譬如是不是数据太少了,显得进度太快。是不是server对请求的回应的方式。
恩,对于不是基于http的下载,比如sftp(其实有问题的,另论)我不得不后台开多线程来下载,还有同一个浏览器开多标签,然后下载,会遇到session相同的问题,这时候又不得不自己写唯一key来区分,真是麻烦啊
最后还是决定用基于http的下载....让浏览器去执行吧
{
document.getElementById("zhaopin").innerHTML="<div id='loading'> 数据加载中,请稍后。<br /><img src='image/loading.gif' /></div>";
var xmlHttp=initajax();
var url="zhaopinsql.php?q=" + q+"&pagesize="+ps+"&pageno="+pn;
url=url+"&sid="+Math.random();
xmlHttp.open("GET",url,true);xmlHttp.onreadystatechange=function(){ajaxcallback(xmlHttp,"zhaopin","<div id='loading'> 数据加载中,请稍后。<br /><img src='image/loading.gif' /></div>")};xmlHttp.send(null);
}function loadarea()
{var xmlHttp=initajax();
var url="areasql.php";
url=url+"?sid="+Math.random();
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange=function(){ajaxcallback(xmlHttp,"fenlei","数据加载中,请稍后。<img src='image/loading.gif' />")};
xmlHttp.send(null);}
function ajaxcallback(xmlHttp,showid,loadingshow)
{ if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
document.getElementById(showid).innerHTML=xmlHttp.responseText;
}
}
else
{
document.getElementById(showid).innerHTML=loadingshow;
}
}