jQuery&;jqTouch-ajax.load问题
我认为我的问题更多地在于我的方法,更多地应用于jquery,但这里发生了一些奇怪的事情 我正在使用jQuery和jqTouch。我的html是:jQuery&;jqTouch-ajax.load问题,jquery,ajax,jqtouch,Jquery,Ajax,Jqtouch,我认为我的问题更多地在于我的方法,更多地应用于jquery,但这里发生了一些奇怪的事情 我正在使用jQuery和jqTouch。我的html是: <div id="home" class="current"> <div class="toolbar"> <h1>Header</h1> </div> <ul class="rounded"> <li class="a
<div id="home" class="current">
<div class="toolbar">
<h1>Header</h1>
</div>
<ul class="rounded">
<li class="arrow"><a href="#currentloc">Current Location</a></li>
</ul>
</div>
<div id="currentloc">
<div class="toolbar">
<h1>Nearby</h1>
</div>
</div>
如您所见,这将完全取代#currentloc的内容。我不确定如何在不替换已有内容的情况下附加results.php的内容。我已经考虑过将ajax加载请求放在append中:
$(this).append(load('results.php'));
但那完全不起作用
知道怎么办吗
更新
有一件事我试过了,但感觉有点笨拙,那就是
$('#currentloc').bind('pageAnimationEnd', function(e, info){
$(this).append('<ul></ul>');
$(this).find('ul').load('results.php');
});
$('currentloc').bind('pageAnimationEnd',函数(e,info){
$(this.append(“
”);
$(this.find('ul').load('results.php');
});
感觉有更好的解决方案。jquery中的load函数将替换内容,因此如果希望保留当前内容,必须创建另一个元素。 如果删除对find函数的调用,可以使代码稍微短一些
$('#currentloc').bind('pageAnimationEnd', function(e, info){
$(this).append($('<ul />').load('results.php'));
});
$('currentloc').bind('pageAnimationEnd',函数(e,info){
$(this.append($('
').load('results.php');
});
或
$('currentloc').bind('pageAnimationEnd',函数(e,info){
$('
').load('results.php').appendTo(this);
});
$('#currentloc').bind('pageAnimationEnd', function(e, info){
$(this).append($('<ul />').load('results.php'));
});
$('#currentloc').bind('pageAnimationEnd', function(e, info){
$('<ul />').load('results.php').appendTo(this);
});