JQuery的 - 阿贾克斯负荷 [英] JQuery - ajax load
本文介绍了JQuery的 - 阿贾克斯负荷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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 );
}
} );
这篇关于JQuery的 - 阿贾克斯负荷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文