var timer;
        var threadKey = Math.random().toString().replace("0.", "");//当前进程标识
        //下面是查询执行进程的函数
        function checkProgress() {
            $.ajax({
                type: "post",
                url: "../../tools/data_copy.ashx?act=check_progress",
                dataType: "json",
                data: "threadKey=" + threadKey,
                success: function (data) {
                    alert(data.msg);
                    if (data.msg == "1") {
                        $(".msg").html(data.msgbox);
                    }
                },
                error: function (data, status, e) { }
            });
        }
        //每隔500毫秒查询一次执行状态
        timer = setInterval("checkProgress()", 500)
                
        $(function () {
            var idlist = "<%=idlist %>";
            //AJAX执行一个线程,该线程可能会耗时比较长,因此在执行过程中每隔500毫秒用checkProgress()函数查询一次执行进度,但经检测每次都要等这整个进程结束后checkProgress()才开始执行,是不是因为jquery的ajax模块不支持多线程并发呢?
            $.ajax({
                type: "post",
                url: "../../tools/data_copy.ashx?act=copy_category&threadKey=" + threadKey,
                dataType: "json",
                data: "idlist=<%=idlist %>&random=" + Math.random(),
                success: function (data) {
                    clearInterval(timer);
                },
                error: function (data, status, e) {
                    clearInterval(timer);
                    $(".msg").append("<br /><font color='red'>× 执行中出错,执行终止</fong>");
                }
            })
        })

解决方案 »

  1.   

    因为你这两个请求都用了一个文件data_copy.ashx,你分两个文件就可以同时异步进去互不干扰。 
      

  2.   

    不是不能并发,是你的ashx不能同时响应或响应时间过长
      

  3.   


    这不可能啊,ashx和aspx一样啊,在服务端肯定是能同时响应很多个请求的
      

  4.   

    timer = setInterval("checkProgress()", 500) 放到success里面
      

  5.   

    js是个单线程的工作方式。所以ajax肯定不是多线程的。
      

  6.   

    没有听过ajax 多线程 到时听过异步