Why would this not work for me ? It's an AJAX POST request to a php script, the script has been tested and works fine with fixed variables.
The request is as follows
$.ajax({ type: "POST", url: url, data:{serial:id}, contentType:"application/json; charset=utf-8", dataType: "json", success: function(data){} My php is
<?php header("Access-Control-Allow-Origin: *"); header('Content-type: application/json'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo 'POSTed'; } //to test post $account = $_POST['serial']; ....etc
which is followed my a MySQL request.
And from my console everything looks fine, except I get " Undefined index: serial" as my response. I have tried constructing my POST variables many different ways. It come from source which when viewed shows the correct variable.
var id = localStorage.userAccount;
application/json?var_dump($_POST)and check what is received.alert()orconsole.logbefore the ajax call to see the value ofserial