duanjia9577 2013-12-02 02:04
浏览 39

Jquery ajax调用包含ajax调用的php页面

I 've got 2 pages

1)index.php

2)feedy.php

1)In index.php i have this code:

   $.ajax({        type: 'GET', 

            url: 'feedy.php?n=<?echo $nnn?>',  
            data: { get_param: 'value' }, 
            success: function (data) { 
                                 var names = data


                $('#content').html(data);           
            }
        });

2)In feddy.php i have this code:

for (i=0;i<=10-1;i++){

$.ajaxSetup({async: false});
 $.post( 
             'addme.php',
             { txt: con, lnk:ln,addr:'".$addr."' },
             function(data) {
                $('#stage').html(data);

             }

}

As you can see i have on page calling another page that makes 10 calls of another page.

The problem: index.php calls feedy.php BUT it only waits to get the php output and not the ouput of the javascript code . Can i make it wait so that in feedy.php all calls can be done ?

Another solution i think could work is to find a way to send a signal to index.php that feedy has finished making calls .

Please help me beacause i can't find a solution :(

  • 写回答

3条回答 默认 最新

  • dousunle5801 2013-12-02 02:08
    关注

    inside of the For loop in feddy.php, have it return a completed value to index.php, so it doesn't return until the loop is done. Or more appropriately, so that the javascript doesn't continue on index.php until the loop is done.

    for (i=0;i<=10-1;i++){
    
        $.ajaxSetup({async: false});
        $.post( 
                 'addme.php',
                 { txt: con, lnk:ln,addr:'".$addr."' },
                 function(data) {
                    $('#stage').html(data);
    
                 }
    
        if(i = 8) { //right before the i++ for the last execution
            return 'positive value';
        }
    }
    

    and then for index, add an if statement to your success

     $.ajax({        type: 'GET', 
    
            url: 'feedy.php?n=<?echo $nnn?>',  
            data: { get_param: 'value' }, 
            success: function (data) { 
                if(response=='positive value') {
                   var names = data
    
    
                  $('#content').html(data);           
               }
            }
        });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度