主调文件index.html <script type="text/javascript"> function getProfile(str) { var arr = str; document.getElementById('aaa').innerHTML = arr.nick; } </script> <body><div id="aaa"></div></body> <script type="text/javascript" src="http://www.openphp.cn/demo/profile.php"></script> 被调文件profile.php <?php $arr = array( 'name' => '陈毅鑫', 'nick' => '深空', 'contact' => array( 'email' => 'shenkong at qq dot com', 'website' => 'http://www.chinaz.com', ) ); $json_string = json_encode($arr); echo "getProfile($json_string)"; ?> 输出结果:深空