I have been unable to pass variable from code igniter controller to a javascript variable
I have a controller that runs a model to return a number
$tot_count = $this->model_users->tot_count();
Than in the header of the view I'm trying to get the value of $tot_count. I have tried several things but I'm unable to get the value passed as
$(document).ready(function(){
var total_count = <?php $tot_count;?>
alert("Value: " + total_count);
});
But get nothing, please help!
var total_count = '<?php echo $tot_count;?>';
? – Abhik Chakraborty Apr 2 at 21:05var total_count = <?php $tot_count;?>
should bevar total_count = <?php echo $tot_count;?>
– cale_b Apr 2 at 21:05