问题:目前我的网页只显示结果,但作为随机位置和谷歌.js不会开始。如果我在 concole 中排除故障,它显示找不到 game_statistics.inc。但它就在那里。这可能是访问问题,因为js文件在web文件夹中,而game_statistic.inc是访问上方的文件夹?如何解决?我应该如何在 html 文件中回显结果,以达到我想要的位置?
client/src/sms/gamestatistics.inc file
$GAnalytics = "SELECT GAnalyticsEST, GAnalyticsRUS FROM GAME_game WHERE id = ".$GID." ; ";
$res= mysql_query($GAnalytics);
$resul = array();
while ($row = mysql_fetch_array($res))
array_push($resul, array('GAnalyticsEST' => $row[0], 'GAnalyticsRUS' => $row[1] ));
echo json_encode(array("resul"=>$resul));
客户端/网络/谷歌.js代码:
$(document).ready( function() {
done();
});
function done() {
setTimeout( function() {
updates();
done();
}, 9000);
}
function updates() {
$.getJSON( '../src/sms/game_statistics.inc', function(data) {
$("ul").empty();
$.each(data.resul, function(){
$("ul").append("<li>GoogleEST: "+this['GAnalyticsEST']+"</li><li>GoogleRUS: "+this['GAnalyticsRUS']+"</li><br />");
});
});
}
您无法访问
它,因为它位于网络无法访问的文件夹中。如果你的浏览器无法访问它,浏览器正在执行的javascript也无法访问。
你需要使用 PHP 来访问 Apache 安装之外的东西。因此,要么将该php文件移动到Apache www dir,要么制作一个脚本来包含它。
<?php require_once('../../file_outside_www.php'); ?>