There is a display of posts with a load on WP, by type VK or Facebook. You need to make the appearance of Loader.gif when scrolling the page down, it is at the moment that new posts are loaded.
Tried many ready-made solutions, but nothing could be applied.
How can I do?
Uploader code:
jQuery (FUNCTION ($) {
$ (Window) .Scroll (Function () {
var bottomoffset = 2000; // indent from the lower boundary of the site, to which the user should smoke, so that new posts do
VAR DATA = {
'Action': 'Loadmore',
'Query': True_Posts,
'Page': Current_page
};
If ($ (Document) .ScrollTop () & gt; ($ (Document) .Height () - Bottomoffset) & amp; & amp; $ ('Body'). Hasclass ('Loading')) {
$.ajax ({
URL: AJAXURL,
Data: Data,
Type: 'Post',
Beforesert: Function (XHR) {
$ ('Body'). AddClass ('Loading');
},
SUCCESS: FUNCTION (DATA) {
if (DATA) {
$ ('# true_loadmore'). Before (DATA);
$ ('BODY'). Removeclass ('Loading');
CURRENT_PAGE ++;
}
}
});
}
});
});
Answer 1, Authority 100%
It’s simple. In $ .ajax there are such things as Beforesend (before sending a request) and Complete (when the request is made)
$. Ajax ({
beforeSend: function () {
$ ( '# Loader') show ().;
},
complete: function () {
$ ( '# Loader') hide ().;
}
});