我写的jQuery阿贾克斯简单的负载内容:jQuery的AJAX加载内容两次
$('.bar a[rel]').live('click', function() {
if($('.modal-'+ $(this).attr('rel')).length == 0) {
$.ajax({
url: 'users/'+ $(this).attr('rel'),
success: function(data) {
$('header + .container').children().animate({
'height': 0,
'padding': 0,
'opacity': 0
}, 500, function() {
$(this).remove();
$(data).hide().appendTo('header + .container').fadeIn(1000);
});
}
});
}
return false;
});
为什么这段代码加载内容(appendTo)两次?
更多信息? –
仅供参考,'.live()'从jQuery 1.7开始已弃用,您应该使用'.on()'http://api.jquery.com/live/。而'成功'将很快被弃用,你应该使用'.done()'来代替。 http://api.jquery.com/jQuery.ajax/ – wakooka
@jerome参数与'.ajax'方法的'success'属性不被弃用。正如您所指出的那样,弃用的是'jqXHR.success'方法,它已被'.done'取代。 – nbrooks