簡體   English   中英

將php json編碼的變量傳遞給jquery函數

[英]Passing a php json encoded variable to a jquery function

如何使用codeigniter將php json編碼變量傳遞給jquery函數? 我的代碼

 $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('graph', $data);

並在我的graph.php中; 我有這個,

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

您必須echo顯變量:

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

另請參見CodeIgniter的View用戶指南

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM