My JavasSript sends a request:
var jax = new XMLHttpRequest(); jax.open("POST", "http://localhost/some.php", true); jax.setRequestHeader("Content-Type", "application/json"); jax.send(JSON.stringify(jsonObj)); jax.onreadystatechange = function() { if(jax.readyState === 4) { console.log(jax.responseText); } }
Now all my php are:
print_r($HTTP_RAW_POST_DATA); print_r($_POST);
The output from the source data is an object string, but the mail array is empty.
{"name" : "somename", "innerObj" : {} ... } Array ( )
I need to get it in the correct format for the $_POST variable, and jquery is not an option.
source share