douye2488 2018-03-05 06:16
浏览 536

如何在一个请求完成后调用多个ajax请求

created two functions i want to call the get_name_from_id when my first ajax function get successful but it is not working when i add alert in get_name_from_id function after jsonstring like alert("xyz") it shows but ajax part not exectue

   function get_name_from_id(){
    var team_name = ("sahil","krishna");
   var jsonString = JSON.stringify(team_name);
    $.ajax({
    dataType:"json",
    type:"POST",
    url:"fetchidwithname.php",
    data: {team_name : jsonString},
    cache: false,
    success:function(a)
    {
        alert(a);

       }        
    });
   }

$("#matchbet").click(function(){
var matchlist = $("#match_list option:selected").val();
var jsonString = JSON.stringify(matchlist);
$.ajax({
    dataType:"json",
    type:"POST",
    url:"selectedmatch.php",
    data: {matchlist : jsonString},
    cache: false,
    success:function(currentmatch)
    {

    var current_bettable  =  team1 + "_vs_"+ team2 + matchdate;
    var bet_team= '<select id="betting_team"><option value='+ team1 +'>'+ currentmatch.team1 + '</option><option value='+ team2 +'>'+ currentmatch.team2 + '</option></select>';
    $("#teamholder").html(bet_team);
    $("#current_match_table").val(current_bettable);
    get_name_from_id();
        }
    });



});
  • 写回答

1条回答 默认 最新

  • douchong4730 2018-03-05 06:57
    关注

    You can use complete method of ajax

    Call your function get_name_from_id() in complete method instead of success

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿