dongzhuo1880 2012-06-15 14:16
浏览 83

jquery多个ajax请求 - 导致php对象出现问题

I am trying to process and update query for 1000 items at a time. I tired settings cache to false, and even tried setTimeout to have a pause between requests. Each request should take 5-6 seconds and then the process will never timeout, but after 4-5 requests it reaches server execution limit.

The problem is I need to use PHP objects in my update query. every request seems to take longer so it seems the objects are looping in PHP

Is there anyway to stop this happening?

Here is the javascript code

function processIndex() {
    $.ajax({
        url: responder,
        dataType: "json",
        data: data,
        cache: false,
        async: false,
        error: function(XMLHttpRequest, textStatus, errorThrown){
        //  alert('status:' + XMLHttpRequest.status + ', status text: ' + XMLHttpRequest.statusText + ' LIMIT ' + limitFrom + ', ' + limitTo);
            limitFrom = limitTo;
            limitTo  += 1000;
            processIndex('indexPrices');
        },
        success: function(data) {
                    limitFrom = limitTo;
                    limitTo  += 1000;
                    setTimeout(function() {
                        processIndex();
                    }, 1000);
                }
            });
        }
    });
}
  • 写回答

1条回答 默认 最新

  • dongmu5106 2012-06-15 14:24
    关注

    You can use http://www.protofunc.com/scripts/jquery/ajaxManager/

    OR

    https://gist.github.com/2470554

    To queue up the ajax requests.

    Another way of doing this is to send few records (say 50 records at a time) and loop through them in server side code.

    You can combine these 2 solutions to get optimum result

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿