for (var i = 2; i < rows.length - 2; i++) {
                    var onlielists = new Array();
                    var orglists = new Array();
                    var destlists = new Array();
                    var times = new Array();
                    airline = rows[i].cells[0].innerText;
                    org = rows[i].cells[1].innerText;
                    destcity = rows[i].cells[2].innerText;
                    orgTime = rows[i].cells[3].innerText;
                    flyno = rows[i].cells[4].innerText;
                        $.ajax
                    ({
                        type: "POST",
                        url: "uploadfile_xintianyou.aspx?type=search",
                        data: {
                            "airline": airline,
                            "org": org,
                            "destcity": destcity,
                            "orgtime": orgTime,
                            "searchScope": searchScope,
                            "pageNo": pageNo,
                            "directFlag": directFlag,
                            "flightType": flightType,
                            "sortCode": sortCode,
                            "sortCode1": sortCode1,
                            "ws": ws,
                            "method": method,
                            "callbackid": callbackid,
                            "evalMode": evalMode,
现在我的数据时一次性全部提交到后台了.数据量大了就卡死了。现在我希望ajax每次向后台提交5次数据。然后5条执行完过后在传5条执行,这个样子。哪位能帮忙把代码完善哈不?万分感谢!!!
急啊,哥哥些

解决方案 »

  1.   

    这样的话 LZ就不要直接这么写for循环了
    可以加一个变量 temp
    每发一次 并且收到回调函数后temp+1
    当temp=5时,再去重新调用到 发数据的方法,并且将temp置为1如此反复  就行了  可能要多加几个方法来控制一下  
      

  2.   

    大概示意写了一下的function postBack(startIndex) {
    if(startIndex > totalCount) {
    return;
    }
    var data = [];
    for(var i = startIndex; i < startIndex + 5 && i < totalCout; ++i) {
    //组装数据
    }
    $.ajax({
    //参数配置
    ...
    //
    success: function(data) {
    postBack(startIndex + 5);
    }
    });
    }
      

  3.   

    zhujiazhi   startIndex这个是什么意思? startIndex这个又是什么意思呢?