开发者

Passing a php json encoded variable to a jquery function

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜