php入门(4) 解析json对象
扫描二维码
随时随地手机看文章
function logging()
{
var x = new XMLHttpRequest();
x.onreadystatechange =function()
{
if(x.readyState == 4) {
if(x.status == 200) {
console.log("The server replied with: " + x.responseText);
txt.text = x.responseText;
}
}
};
var xxx = new Object;
xxx.id=289672082;
xxx.pwd = '12345';
var pcode= JSON.stringify(xxx);
x.open("GET","http://localhost/mycode/Test/index.php?code="+pcode);
x.send(null);
}
解析
$pcode = $_GET['code'];
$obj = json_decode($pcode);
echo $obj->id . "," . $obj->pwd;