Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7761017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:02:39+00:00 2026-06-01T14:02:39+00:00

I have a slider on homepage, i am trying to load next five posts

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:02:40+00:00Added an answer on June 1, 2026 at 2:02 pm

    What slider.js are you using? You can probably add an event listener to reinitialize the slider after getting the data from your php script. Something like this, though it will vary based on how the slider works.

    $('.nextfive').click(function () {
        $.get("<?php echo admin_url('admin-ajax.php'); ?>",
              {action :'next_five', next   : 5},
              function (resp) {
                  $('#navi').slideDown("slow");  
                  $("#slidercontainer").html(response)
                  $("#slidercontainer").slider(); /* This will change depending on
                                                   * the library you are using */
        });
    })
    

    Also, a couple of things about your coding style:

    1. When you are getting data such as the next five posts and not modifying the data, always use GET and not POST. Conventionally, GET is always used unless you are modifying something on the server, in which case you use POST.
    2. jQuery.* can be replaced by $.*, see my example above.
    3. The simplest way to attach a click handler to an element (i.e. make something happen when you click on something) is to use the $(elem).click() function in jQuery, see my example.

    If you give more details about the slider you’re using, I can help with more specific code.

    Good luck!
    4. Other small simplifications, you don’t need to define the var data if you’re using it only once, again see my example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an slider animation but on clX.click event #close div hides before it
I have a slider I've made, the slider part works correctly, but I'm trying
I wish to have a slider similar to they use. http://www.koovs.com/apple-ipod Can anyone suggest
I'm trying to build a site that runs without refreshes, using Jquery and PHP
I am trying to implement a one page slider to a homepage and I
I am currently using the nivo slider on my homepage, to show different images.
I have installed the jQuery UI slider, but it doesn't show in my code.
I have a featured content slider on my homepage here: etiquetteplus.net That slider loads
I have installed the Nivo Slider (http://nivo.dev7studios.com/) that uses jQuery on my site which
I have a slider made with jQuery UI, which works completely fine, except that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.