Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JScroll load Ajax content

Tags:

jquery

How do I use JScroll to load an ajax content? on the site of jscroll it doesn't have any example on loading an ajax content. Can anyone assist me on this. Also if JScroll cannot do this can anyone give me a link for an Infinite scroll for Jquery?

On the Jscroll examples. Loading a second page is something like this

<div class="scroll">
    <h3>Page 1</h3>
    <p>Content here...</p>
    <a href="example-page2.html">next page</a>
</div>

As you can see you have to define the 'a' tag to have an href pointing to the second page to load. But I was thinking of having to pass a function that will retrieve the content dynamically something like this

$('.scroll').jscroll({
    ajaxfunction: function() {
        // Return dynamic content here
    }
});

Thanks.

like image 852
MadzQuestioning Avatar asked Mar 24 '26 09:03

MadzQuestioning


1 Answers

The ajax content is retrieved automatically from the URL defined in the href of the nextSelector element, which is the a tag in the example. That is all you have to do. The ajax request is made for you by the plugin.

You can also use the callback option to pass a function in which you can manipulate the DOM or the data returned at the end of each scroll request. The automatic loading of the next page by either scrolling or clicking is the intended behavior of the plugin, however.

like image 167
Philip Avatar answered Mar 25 '26 22:03

Philip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!