jQuery global variable problem

前端 未结 6 818
伪装坚强ぢ
伪装坚强ぢ 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:09

    The AJAX function is asynchronous. It will run in the background and when it is done getting the ajax.php page it will run the success function.

提交回复
热议问题