I have a slider on homepage, i am trying to load next five posts in it on click of a button using Ajax. When i use Jquery .post to load the html of next five posts, the slider disappears.The cause being that a script called 'slider.js' does not work on the newly added html. I tried using .live() but it didn't work, i can see the response from Ajax call in my console so i know tha call is working. I tried including the js file in Ajax response but it doesn't fire even then. The js file is a long file with a lot of functions, i cannot enclose it in one function as suggested by some people on the forum. How would i reload the slider.js to make it work? Here is the ajax .post() code.
$(function() {
$('.nextfive').live('click', function() {
var data = {action: 'next_five',next: 5};
jQuery.post("<?php echo admin_url('admin-ajax.php'); ?>", data,
function(response) {
$('#navi').slideDown("slow");
$("#slidercontainer").html(response);
},"html");
});
});
Edit: check the page at http://axactsoft.com/samplewp/ and click the button on top 'click five'. The code of files is pasted here http://pastebin.com/4iS6Ey10