jquery - Google App Engine, AJAX is returning string of contents of PHP file insteasd of JSON


I have been trying to get working the datatable in GAE with PHP as a runtime but somehow it is returning the actual page content instead of json response. Following is the app.yaml file.

application: app353
version: 1
runtime: php
api_version: 1
threadsafe: yes

- 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.php

PHP/HTML snippet


<script src="./js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="./js/jquery.dataTables.js">     
<link rel="stylesheet" type="text/css" media="all" href="./css/jquery.dataTables.css" /> 

 "ajax": './php/genjsonphp.php' 
 } );
} );

 <table class="display" id="example">


directory structure are as follows


Content snippet from getjsonphp.phh

header('Content-Type: application/json');
header('Content-Type: application/json');
echo $strjSon;

Log from google app engine.

default: "GET /css/jquery.dataTables.css HTTP/1.1" 304 -

default: "GET /php/genjsonphp.php HTTP/1.1" 200 675

Spent lots of time debugging but no luck Can someone point to the error or documentation please.

Thanks, Sachin




From your yaml config it is fairly obvious that to exec php/genjsonphp.php you need to request the url '/php/genjson' and not './php/genjsonphp.php' as your js does currently. Either fix the config or fix the js, this is pretty trivial and if you really "spent lots of time debugging" you may be beyond help, sorry.




The .* url mapping will take precedence over the /php/genjson based on the order they're specified in your app.yaml file. You'll need to change accordingly if php/genjsonphp.php is the actual script you're trying to invoke.

People are also looking for solutions to the problem: php - HTTP to HTTPS Redirection Issue


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.