I have a simple JavaScript code like this:
var xhr = new XMLHttpRequest, action = "action=latest", page = "http://192.168.1.115/wp-content/themes/HSV%20Saints/setphoto.php";
xhr.open("POST", page, true);
xhr.setRequestHeader("Content-type", "application-x-www-formurlencoded");
xhr.send(action);
xhr.onload = function(){
console.log("XHR Onload");
console.log(xhr.responseText);
console.log(action);
}
I have a PHP script like this:
<?php
$action = $_POST['action'];
echo $action;
echo 'Test message';
?>
The $action variable is not showing up, but the 'Test message' is (in the console). I don't understand why it can't send var action