-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyloadmore.js
38 lines (36 loc) · 1.07 KB
/
myloadmore.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
jQuery(function($) {
var count = 5;
$('.misha_loadmore').click(function() {
var button = $(this),
data = {
'action': 'loadmore',
'query': {
"posts_per_page": 3,
"orderby": "date",
"order": "DESC",
},
'page': params.current_page,
'cat': params.cat,
'offset': count
};
$.ajax({
url: params.ajaxurl,
data: data,
type: 'POST',
beforeSend: function(xhr) {
button.text('Loading...');
},
success: function(data) {
if (data) {
button.text('More Post').prev().after(data);
params.current_page++;
count = count + 1;
if (params.current_page == params.max_page)
button.hide();
} else {
button.remove();
}
}
});
});
});