6
I passed via ajax those values:
$.ajax({
url: '/loterias/cadastro.php',
type: "POST",
data: "{'numeros': '" + numeros + "', 'jogo':'" + jogo + "'}",
dataType: 'application/json; charset=utf-8',
success: function (data) {
debugger;
alert(data);
},
error: function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
alert("responseText: "+xhr.responseText);
}
});
In PHP (registration.php) I received so (I do not know if it is correct):
$data = json_decode(file_get_contents('php://input'), TRUE);
How can I echo the value "numbers" and "game"?
You are right, the
json_decode
is failing because an invalid JSON is being posted.– bfavaretto