success: function(json) {
for (var i = 0; i < json.length; i++) {
var response = json[i];
$('#rv-container').html('<p>' + response.name + '</p>' + '<span>' + response.id + '</span>');
}
$('#history_tracking').hide();
}
在success回调中,$(#rv-container).html()不起任何作用,但.prepend会起作用。
为什么jQuery在success回调中不允许 .html?通过ajax加载的html不断堆积已加载数据的顶部,因此,它不会替换#rv-container中当前的数据。
HTML:
<div id="bottom-toolbar">
<div id="rv-facet">
<div id="rv-fix">
<li id="rv-title">
Recently Viewed <span class="total_viewed"></span>
<div id="rv-total" style="float:right; margin-right:25px;"></div>
</li>
</div>
<div id="rv-content">
<div id="rv-container">
<div id="history_tracking"></div>
</div>
</div>
</div>
</div>
有可以用prepend替换div的内容吗?