Javascript 从.done返回值$this@jquery ajax

Javascript 从.done返回值$this@jquery ajax,javascript,jquery,Javascript,Jquery,但是,$this在.done子函数中不起作用。我在这里做错了什么?这是因为此未引用回调中的元素项 尝试围绕一个新值关闭 control_td.each(function(){ $.ajax({ url: 'control.php?udid='+$(this).attr('udid'), cache: false, async: true }).done(function(data) { $(this).html(data); }); }); 这是因为此未引用回调中的元素项 尝试

但是,
$this
.done
子函数中不起作用。我在这里做错了什么?

这是因为
未引用回调中的元素项

尝试围绕一个新值关闭

control_td.each(function(){
$.ajax({
  url: 'control.php?udid='+$(this).attr('udid'),
  cache: false,
  async: true
}).done(function(data) {
  $(this).html(data);
});
});

这是因为
未引用回调中的元素项

尝试围绕一个新值关闭

control_td.each(function(){
$.ajax({
  url: 'control.php?udid='+$(this).attr('udid'),
  cache: false,
  async: true
}).done(function(data) {
  $(this).html(data);
});
});
试试这个:

control_td.each(function(){
var $self = $(this); // magic here!
$.ajax({
  url: 'control.php?udid='+$(this).attr('udid'),
  cache: false,
  async: true
}).done(function(data) {
  $self.html(data);
});
});
试试这个:

control_td.each(function(){
var $self = $(this); // magic here!
$.ajax({
  url: 'control.php?udid='+$(this).attr('udid'),
  cache: false,
  async: true
}).done(function(data) {
  $self.html(data);
});
});

您还可以设置
$.ajax
上下文
选项

control_td.each(function () {
    var $this = $(this);
    $.ajax({
        url: 'control.php?udid=' + $this.attr('udid'),
        cache: false,
        async: true
    }).done(function (data) {
        $this.html(data);
    });
});

您还可以设置
$.ajax
上下文
选项

control_td.each(function () {
    var $this = $(this);
    $.ajax({
        url: 'control.php?udid=' + $this.attr('udid'),
        cache: false,
        async: true
    }).done(function (data) {
        $this.html(data);
    });
});