I have a problem in jQuery, on how to get data from my codeigniter controller to jQuery function.
I am having a progress bar in jQuery and i need the value of the progress bar will be depend on the output of the controller; i use json_encode in controller.
Jquery
$(function() {
$( "#progressbar" ).progressbar({
value: //get value from the controller json_encode
});
});
Controller
public function countScoreCh(){
$id = $this->session->userdata('userID');
$data['getScore'] = $this->lawmodel->battleUserID($id);
foreach($data['getScore'] as $row){
$scoreCH = $row->challengerScore;
echo json_encode(
array(
'scoreCH' => $scoreCH,
)
);
}
}
the progress bar function will be something like this.
$(function() {
$( "#progressbar" ).progressbar({
value: //jsn.scoreCH value
});
});
Is there's a possible way of doing it? I don't know if using json_encode is the correct way. But any solution will do..:)
Thanks..
$id = $this->session->userdata('userID');could be php code. Are you using php?