Reputation: 406
I am using that:
$.post("src/php/login.php",{
"user" : {
"username" : $("#login").val(),
"password" : $("#pass").val(),
}
}, function ( response ) {
alert(response);
$("#but").removeAttr("disabled");
});
And how I can get this json object at php:
$q = json_decode($_POST[?]);
What I have to set of '?' ?
Upvotes: 2
Views: 818
Reputation: 49909
You can do $_POST['user']
on the PHP side. And you don't have to do a json_decode, because it will be posted as an array with this structure. e.g.:
$_POST['user']['username']
$_POST['user']['password']`
Upvotes: 3