Everything was working a couple of days ago, but all of a sudden it is no longer working. I think I have tried everything, but no change, so coming to SO as last resort!
I have gone through this article and checked my php.ini file, and the post_max_size is set to 8M
Ajax request from JS:
$.ajax({
url: "getFromDB.php",
type: "post",
dataType: 'json',
headers: {'Content-Type': 'application/json'}, // Tried with and without
data: { action: "getRouteList" },
success: function(obj){
alert("Yay!");
}
});
myPage.php
// From this SO answer: http://stackoverflow.com/a/14794856/4669619
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
var_dump($rest_json);
var_dump($_POST);
getRouteList(); // Works
if (isset($_POST["action"]) && !empty($_POST["action"])) {
file_put_contents('function_result.txt', "Action: Set" . PHP_EOL . PHP_EOL, FILE_APPEND);
$action = $_POST["action"];
if ($action == "getRouteList") {
getRouteList(); // Doesn't work (b/c $_POST isn't set)
}
} else {
file_put_contents('function_result.txt', "Action: Not set!" . PHP_EOL . PHP_EOL, FILE_APPEND);
}
var_dump output:
string(19) "action=getRouteList" // $rest_json
NULL // $_POST // NULL b/c of '='?
function_result.txt output
Action: Not set!
Firebug info: