创建了两个函数,当我的第一个ajax函数成功时,我想调用get_name_from_id但是当我在gets_from_id函数中添加警告之后它不起作用jsonstring如alert(“xyz”)它显示但是ajax部分不是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();
}
});
});
答案 0 :(得分:0)
您可以使用ajax的complete
方法
使用get_name_from_id()
方法而非complete
success