I need to replace the value 17 for a variable coming from php.php:
$(function() {
$("#test").paginate({
count : 17,
start : 1,
display : 12,
border : true
...
});
});
I tried this (didn’t work):
$(function(){
$("#test").paginate({
count : $.post("php.php",function(result){ console.log(result['count']) }),
start : 1;
display : 12;
border : true
...
});
php.php
$query = mysql_query("SELECT * FROM test");
$count = mysql_num_rows($query);
json_encode($count);
I am trying this way but i don’t know if it’s the best way to do that. I appreciate any suggest and help.
jQuery Ajax function are asynchronous, or in other words, return instantly then call a callback when they complete. You need to set the count inside the callback like so:
As per our comments, for multiple values you would need something like
PHP: