我有一个脚本,使用GD和PHP在世界地图上绘制所请求的国家的颜色。 PHP请求被复选框调用。它看起来像是你调用PHP脚本太快,然后返回一个“Xed out”错误图像。有没有办法用setTimeout或其他东西排队PHP请求,所以新的检查事件永远不会失败?得到偶尔的错误,而不是PHP图像
下面是JavaScript调用由的onclick事件:
function onBoxClicked(frame, country){
var randomNumber = Math.floor(Math.random()*100000001);
if (document.getElementById(country).checked == true){
window.parent.document.getElementById('world_map').src=(country)+".php?r=" + randomNumber;
}else if (document.getElementById(country).checked == false){
window.parent.document.getElementById('world_map').src=(country)+"_unload.php?r=" + randomNumber;
}
}
下面是一个典型的国家PHP文件(我知道有一些垃圾,可以删除):
<?php
session_cache_limiter('nocache');
$cache_limiter = session_cache_limiter();
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");// Date in the past
$ip=$_SERVER['REMOTE_ADDR'];
$oldImageName = 'world_map2_users_copy.png';
$newImageName = $ip.'.'.'world_map2_users_copy.png';
if (file_exists($newImageName)){
$im = imagecreatefrompng($newImageName);
}else{
copy($oldImageName, $newImageName);
$im = imagecreatefrompng($newImageName);
}
$syria_color = imagecolorallocate($im, 0, 158, 96);
imagefill($im, 780, 205, $syria_color);
ImagePNG($im, $newImageName);
ImagePNG($im);
ImageDestroy($im);
?>
你能告诉我们包括该行在内的确切错误吗? – Jamescun 2010-04-28 21:58:09