选项1:切换到
success处理程序中数组中的下一个元素。
选项2:同步发出Ajax请求:
全球:
$.ajaxSetup({ async: false });或直接在请求中:
$.ajax({ async: false, type: "POST", url: domain+"/view_tasks/gen_tasks/", dataType: 'html', data: data, success: function(dt){ $this.find('.contChildTasks').html(dt); childs = $this.children('.taskDesc').find('.has_child'); if(childs.length != 0) { genTask(childs); } }});



