infinite scroll javascript
$(window).scroll(function () {
// End of the document reached?
if ($(document).height() - $(this).height() == $(this).scrollTop()) {
$.ajax({
type: "POST",
url: "index.aspx/GetData",
contentType: "application/json; charset=utf-8",
data: '',
dataType: "json",
success: function (msg) {
if (msg.d) {
$(".container").append(msg.d);
}
},
error: function (req, status, error) {
alert("Error try again");
}
});
}
});
<div class="article-feed">
<!-- .articles will be added to .article-feed -->
<article class="article">...</article>
<article class="article">...</article>
...
</div>
<!-- status elements -->
<div class="scroller-status">
<div class="infinite-scroll-request loader-ellips">
...
</div>
<p class="infinite-scroll-last">End of content</p>
<p class="infinite-scroll-error">No more pages to load</p>
</div>
<!-- pagination has path -->
<p class="pagination">
<a class="pagination__next" href="page2.html">Next page</a>
</p>
Also in JavaScript:
- javascript in viewport
- nested array loop in javascript
- loop over keys in object javascript
- mock sqs.sendMessage node js
- referenceerror document is not defined node js
- convert decimal to binary javascript
- how to use if else statement in javascript
- devolver nombre propiedades de objeto javascript
- jquery create element properties
- notify js
- Unexpected end of JSON input while parsing near
- javascript create svg
- get attribute value jquery
- recorrer letra por letra js
- html video tag autoplay not working
- how to change css with js
- find next greater number with same set of digits javascript
- eliminare spazi inizio e fine stringa javascript
- watchman watch-del-all, and react-native start --reset-cache
- js ask before close chrome
- js clone deep
- hidden property input angular 2
- read and save excel with react
- make list in javascript