The following tutorial column will introduce to you two implementation methods of ThinkPHP returning JSON through AJAX. I hope it will be helpful to friends in need!
Method 1:
The php code is as follows:
The code is as follows:$arr = array( 'name'=>$picname, 'pic'=>$pics, 'size'=>$size ); $this->ajaxReturn (json_encode($arr),'JSON');
var d=eval('('+d+')');//json转成object alert(d.pic);
The code is as follows:
$arr['name']=$picname; $arr['pic']=$pics; $arr['size']=$size; $this->ajaxReturn ($arr,'JSON');
alert(d.pic);
The above is the detailed content of Two implementation methods for ThinkPHP to return JSON through AJAX. For more information, please follow other related articles on the PHP Chinese website!