<div id="inner">
Some content...
</div>
现在我需要加载一些文件到内 - 块,但保存的旧内容。
Now I need to load some file into inner-block, but save it's old content.
$('#inner').load( 'pathToFile.html' );
将取代格的旧内容。
Will replace old content of div.
感谢。
所以,按照我的理解我的code应该是:
So, as I understand my code should be:
old = $('#inner').html();
$('#inner').load( 'pathToFile.html' );
$('#inner').html( old + $('#inner').html() );
我会建议不要使用的东西,如'负荷'和其他Ajax助手。他们在我身边 $就的只是包装。关闭我的头顶,也许你想要的:
I'd recommend against using stuff like 'load' and the other ajax helpers. They're just wrappers around $.ajax. Off the top of my head, maybe you want:
$.ajax( {
url: 'pathToFile.html',
type: 'get',
success: function( r ) {
$('#inner').append( r );
}
} );