我一直在尝试使用PHP作为运行时在GAE中使用datatable,但不知何故,它返回的是实际的页面内容,而不是json响应。以下是app.yaml文件。
application: app353
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: .*
script: index.php
- url: /php/genjson
script: php/genjsonphp.phpPHP/HTML代码段
<?php
?>
<script src="./js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="./js/jquery.dataTables.js">
</script>
<link rel="stylesheet" type="text/css" media="all" href="./css/jquery.dataTables.css" />
<script>
$(document).ready(function()
{
$('#example').dataTable(
{
"ajax": './php/genjsonphp.php'
} );
} );
</script>
<table class="display" id="example">
<thead>
<th>Dimensions</th>
</thead>
<tbody></tbody>
</table> 目录结构如下
css/*.css
js/*.js
php/genjsonphp.php
app.yaml
index.php来自getjsonphp.phh的内容片段
header('Content-Type: application/json');
var_dump(json_decode($strjSon));
header('Content-Type: application/json');
echo $strjSon;从google应用程序引擎登录。
默认值:"GET /css/jquery.dataTables.css HTTP/1.1“304 -
默认值:"GET /php/genjsonphp.php HTTP/1.1“200 675
花了很多时间调试,但没人能指出错误或文档。
谢谢,Sachin
发布于 2014-05-28 19:36:54
从您的yaml配置中可以明显看出,要执行php/genjsonphp.php,您需要请求url '/php/genjson‘,而不是'./php/genjsonphp.php’。要么修复配置,要么修复js,这是相当微不足道的,如果你真的“花了很多时间调试”,你可能会无能为力,抱歉。
https://stackoverflow.com/questions/23855933
复制相似问题