代码最后为
ini_set(max_execution_time, 800); ... $data['status'] = 0; log::write(json_encode($data),log::debug); echo json_encode($data); log::write('echo success',log::debug);
运行结果为
[ 2016-07-18t14:50:36+08:00 ] debug: 运行时间:486.8268s[ 2016-07-18t14:50:36+08:00 ] debug: {status:0}[ 2016-07-18t14:50:36+08:00 ] debug: echo success
但是页面没 echo json_encode($data);
f12查看http请求就一直没有返回,但是计算却运行完成了,代码基本都贴全了,只要删除一部分计算时间长的代码,就可以得到返回值,但是我已经设置了max_execution_time,计算也没超过时间
回复内容: 有个以tp3.1框架开发的功能,计算完成后要求返回{status:0}
代码最后为
ini_set(max_execution_time, 800); ... $data['status'] = 0; log::write(json_encode($data),log::debug); echo json_encode($data); log::write('echo success',log::debug);
运行结果为
[ 2016-07-18t14:50:36+08:00 ] debug: 运行时间:486.8268s[ 2016-07-18t14:50:36+08:00 ] debug: {status:0}[ 2016-07-18t14:50:36+08:00 ] debug: echo success
但是页面没 echo json_encode($data);
f12查看http请求就一直没有返回,但是计算却运行完成了,代码基本都贴全了,只要删除一部分计算时间长的代码,就可以得到返回值,但是我已经设置了max_execution_time,计算也没超过时间
ini_set(max_execution_time, 800); ... $data['status'] = 0; log::write(json_encode($data),log::debug); echo json_encode($data); log::write('echo success',log::debug); exit;//退出脚本
$data['status'] = 0;
echo 1;
log::write(json_encode($data),log::debug);
echo 2;
echo json_encode($data);
echo 3;
log::write('echo success',log::debug);
这样试试 看运行到这里没
做的ajax请求?浏览器f12看看请求的链接有没有成功,有没有收到回复。给的信息太少了,补充详细一点。
看不出什么明显的问题,用的xhr做的请求,是不是设置了timeout?导致计算时间过长就忽略返回值了。顺便,建议在echo json前加上header('content-type: application/json');
