So, I have this <div> in which my blog posts are contained. Its class is .post. What I want to do is that every time someone clicks on the recent posts at the widget area, the content is loaded through Ajax instead of refreshing the page.
Here is my code
jQuery(function()
{
jQuery(".umrp-list li a").click(function(){ //here I select the links of the widget
var post_url = jQuery(this).attr("href");
jQuery(".post").html('<div class="loading">Loading Content...</div>');
jQuery(".post").load(post_url);
return false;
});
});
So I have two problems
Whenever I click on a "Recent Posts" link, the content loads where I want it to load, but my webpage is idle/frozen for about 2 seconds after the click. Why is that happening?
When I click for the first time, everything works except the detail I described above. When I click for the second time (another link or even the same) then instead of loading the post I clicked, it loads my whole webpage on that
.postcontainer. Any ideas why this is happening?
preventDefault()action in your click code? Change the click to:click(function(e){Then adde.prventDefault();within the function.