因此,这里是我的,当用户点击一个后续按钮代码:
$('.follow_btn').click(function() {
$(this).html('<img src = "../assets/style_images/loading.gif">');
var userId = $(this).attr('id');
$.post('../assets/scripts/ajax_follow_parse.php', {
userId: userId
}, function(data) {
$(this).html(data);
});
});
这是很高兴的加载GIF来取代它,如上线2.但是,当它返回数据并将其替换为第4行返回的数据时。
如何解决此问题?
重复[$(this)在函数中不起作用](http://stackoverflow.com/questions/7859558/this-doesnt-work-in-a-function),[$(这个)对象在jquery post()之后变得未定义(许多其他的东西)(http://stackoverflow.com/questions/8422872/this-object-becomes-undefined-after-a-jquery-post)。 – 2011-12-30 22:43:18