开发者

Passing a php json encoded variable to a jquery function

开发者 https://www.devze.com 2023-01-12 15:00 出处:网络
How to passa php json encoded variable to a jquery function using codeigniter? My code $data[\'customerlist\'] = $this->customerlist->customerchart();

How to pass a php json encoded variable to a jquery function using codeigniter? My code

 $data['customerlist'] = $this->customerlist->customerchart();
   //print_r($data['customerdata']);
   $data['encoded_data'] = json_encode($data);
   //print_r($data['encoded_data']);
    if(empty($data['encoded_data']))
    {
       $data['comment']='No Record Found !';
    }

   $this->load->view(开发者_JS百科'graph', $data);

and in my graph.php; i have this,

$(document).ready(function() {
 PageViews($encoded_data);
});


You have to echo the variable:

$(document).ready(function() {
   PageViews(<?php echo $encoded_data; ?>);
});

See also CodeIgniter's View User Guide.

0

精彩评论

暂无评论...
验证码 换一张
取 消