jQuery global variable problem

前端 未结 6 814
伪装坚强ぢ
伪装坚强ぢ 2021-01-22 10:58
var id = $(this).children().html();  // id is 5
$.ajax({
   url: \'ajax.php?id=\' + id,
   success: function(data) {
      id = data;   // id is 1
   }
});
if(id == 1){          


        
6条回答
  •  北恋
    北恋 (楼主)
    2021-01-22 11:10

    your if statement executes before your .ajax call completes

提交回复
热议问题