I'm trying to load content into a DIV with jQuery load() but it is not working if the link that calls the function is generated after page load.
var ajax_load = "<img class='loading' src='ajax-loader.gif' alt='loading...' />";
$(".slide_more").click(function() {
$("#ajaxcontent").html(ajax_load).load('p=4324.php #singlePost');
});
and the generated link:
<a href="#" class="slide_more" id="load_basic">LOAD</a>
I've tried using live() and delegate() with no luck:
$(".slide_more").live('click', function() {
$("#ajaxcontent").html(ajax_load).load('p=4324.php #singlePost');
});
The strange thing is that the .slide_more开发者_开发技巧 class also calls a simple jQuery toggle which is working with live().
The jQery snippet with the live() handler added to click() event is working fine. I just had to make sure that the code is at the top of the page before any other code.
加载中,请稍侯......
精彩评论