我读了这篇文章:Why does Google prepend while(1); to their JSON responses?这对PHP脚本有什么帮助吗?我试过这个:
$time=time();
$hash=md5(mt_rand(1,200000));
$arr = array('time' => $time, 'hash' => $hash);
while(1);json_encode($arr);
Ajax返回错误提醒: Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\foo\1.php on line 6
Thank you Girish very much works :
1.php
<?php
$time=time();
$hash=md5(mt_rand(1,200000));
$arr = array('time' => $time, 'hash' => $hash);
echo "while(1);".json_encode($arr);
ajax -side
responseText=req.responseText.substring(9);
var obj=JSON.parse(responseText);
statusElem.innerHTML = obj.hash