function getProfile(str) { var arr = str; document.getElementById('nick').innerHTML = arr.nick; } 复制代码 php文件:profile.php $arr = array( 'name' => '李飞麟', 'nick' => '深空', 'contact' => array( 'email' => 'shenkong at qq dot com', 'website' => 'http://bbs.it-home.org', ) ); $json_string = json_encode($arr); echo "getProfile($json_string)"; ?> 复制代码