简体   繁体   English

jQTouch。 通过ajax重新加载附加的div

[英]jQTouch. Reload appended div by ajax

In jQT AJAX demo(main/index.html), the link doesn't have #sign before it is loaded. 在jQT AJAX演示(main / index.html)中,链接在加载之前没有#sign。

<a href="ajax.html">GET Example</a>

After loading, it becomes like below, replaced by the div id in ajax.html. 加载后,如下所示,由ajax.html中的div id代替。 And the loaded div, whose id is 'get', is appended to the page. 然后将已加载的div(其ID为“ get”)附加到页面上。

<a href="#get">GET Example</a>
...
<div id="get" >...</div>

I wonder how to remove&reload or replace the div as it did at the first time. 我想知道如何像第一次一样删除和重新加载或替换div。 There might be changes in that page, if it is dynamically generated one. 如果该页面是动态生成的,则该页面可能会有更改。 Or is there any other method which does not append div, not change link to '#...' and just leave it as it was? 还是有其他方法不附加div,不将链接更改为“#...”并保持原样?

HTML : HTML:

<a href="#" class="get_btn">GET Example</a>
<div id="get"></div>

jQuery : jQuery的:

$('.get_btn').on('click',function(){
   $.ajax({
     url:'ajax.html',
     type:'GET',
     success:function(html){
       $('#get').html(html);
     }
   });
});

If you still want to use your HTML , so change $('.get_btn') to $('a[href="#get"]') 如果仍要使用HTML, $('.get_btn')更改$('a[href="#get"]')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM