My issue is about getting the global variable to assign it to item.
var cat; // clicked menu , reference for category, global variable
$(window).ready(function() {
jQuery(function() {
$('li.menuItem').click(function(e) {
cat = $('a', this).text();
$.ajax({
type: "GET",
timeout: 30000,
async: false,
cache: false,
global: false,
dataType: "text",
url: 'items.php?genre=' + cat,
success:function (data) {
items(data);// output number of items handled by function items() to make it global
}
});
});
});
function items(data) {
// We want this to show the "results" from the callback function.
console.log(data); // <-- this gives me the right number of items eatch time i click on different category
}
$('.pagination').pagination({
items: ??, <-- my issue is to assign the output data on the fly here,
itemsOnPage: 20,
cssStyle: 'light-theme',
currentPage: 1,
onPageClick: function(pageNumber) {
jQuery(".movies-list").html('loading...');
jQuery(".movies-list").load("connect.php?genre=" + cat + "&page=" + pageNumber);
}
});
});
I couldn't figure out how to resolve now its been a week or more googling and surfing on StackOverflow without success. Thank you in advance
Looks like you are using the simplePagination.js , if so you can use the updateItems
method to update the number of items
function items(data) {
$('.pagination').pagination('updateItems', data);
}
yes true i have some external ref so im posting them here:
"maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css"
"ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.js"
"maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"
"phpflow.com/demo/jquery_ajax_pagination_with_php_demo/dist/simplePagination.css"
"phpflow.com/demo/jquery_ajax_pagination_with_php_demo/dist/jquery.simplePagination.js"
"fontawesome.io/assets/font-awesome/css/font-awesome.css"
"seegatesite.com/bootstrap/css/bootstrap.min.css"
"seegatesite.com/bootstrap/css/simple-sidebar.css"
"seegatesite.com/bootstrap/js/jquery-1.11.2.min.js"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.