In js file I'm sending json object to php file but i don't know how to access to sent object.
first line in code below give me that:{"id":1,"email":"[email protected]","password":"xxxx","location":"London"}
js file
app.showAlert(JSON.stringify(profile));
$.ajax({
type: "GET",
url:"http://www.domain.co.uk/test-login.php",
dataType: 'jsonp',
data: { data: JSON.stringify(profile) },
success:function(json){
// do stuff with json (in this case an array)
app.showAlert(JSON.stringify(json), "Login ok");
},
error:function(){
app.showAlert("Login faild", "Wrong username or password. Please try again.");
},
});
php file:
<?php
header('Content-type: application/json');
$ret=$_GET['data'];
$ret=json_decode($ret, true);
echo '['.json_encode($ret[0]).']';
?>
Php is test, because i want to check if user pass correct details, then I will return json object with 'loggedin' => 1 or so, if not 0
I also tried to access to this object by $ret=$_GET['profile'];, but it didn't help.
My question is: how to pass json object and access to it in php.
print_r? the problem is that i cant check step by step what is going on, because if i dont receive json object I get msgLogin faild.