标签:ci调用json
控制器controller下的welcome.php
public function doJson(){ $data =array(‘a‘,‘b‘,‘c‘,‘d‘); if($_POST[‘k‘]) echo $data=json_encode($data); }
视图view下的json.php
<!DOCTYPE HTML> <html> <head> <script src=\‘#\‘" /js/jquery-1.9.1.min.js"></script> </head> <body> <div id="jj">222</div> </body> <script> $(function(){ $(‘#jj‘).click(function(){ $.post( ‘<?php echo base_url();?>index.php/welcome/doJson‘, {k:1}, function(data){ alert(data[0]); $(‘#jj‘).text(data[0]); },‘json‘); }); }); </script>
本文出自 “王尼美的成人之路” 博客,请务必保留此出处http://8335914.blog.51cto.com/8325914/1531551
标签:ci调用json
原文地址:http://8335914.blog.51cto.com/8325914/1531551