I'm making a $post call to a .php file that return json data. It works just fine if I only use one .php, but if I try including another .php it drops into the .failed callback. I've put together an example here with an included .php that doesn't even do anything.
Javascript:
$.post("/test_php/cgi.php", l_cDB_arg_array, function(o) {
console.log("Returned from db_interface call" + JSON.stringify(o));
console.log(JSON.stringify(o));
l_this.showLayer("top of the world", false);
}).fail(function(response) {
console.log('Error: ' + JSON.stringify(response));
});
First cgi.php:
<?php
include "noop.php";
header("Content-Type: application/json; charset=UTF-8");
$ret = json_decode('{"some":"data"}');
echo json_encode($ret);
Second noop.php
<?php
Result when including noop.php in cgi.php
Error: {"readyState":4,"responseText":"{\"some\":\"data\"}","status":200,"statusText":"OK"}
Result when not including noop.php in cgi.php
Returned from db_interface call{"some":"data"}
Looking at all the .fail arguments I get:
response: {"readyState":4,"responseText":"{"some":"data"}","status":200,"statusText":"OK"}
textStatus: parsererror
errorThrown: SyntaxError: Unexpected token in JSON at position 0
Moving the header to before the include didn't change anything.