Home > Backend Development > PHP Tutorial > php如何接收json

php如何接收json

WBOY
Release: 2016-06-23 13:50:47
Original
867 people have browsed it

	$.ajax({		       cache: true,        type: "POST",        url:"__URL__/index",           data:{name:$("#name").val()},        async: false,       datatype: "json",        error: function(request) {            alert("Connection error");        },      success: function(data) {                       }    });
Copy after login

firebug,看到传过来的是name=%E7%AC%AC%E4%B8%80%E8%BD%AE,我想知道在php后台应该怎么取到name,并输出到前台页面


回复讨论(解决方案)

echo $_POST['name'];

echo $_POST['name'];

输出为NULL要不我也不用发帖了。。

那你看到的就不是 name=%E7%AC%AC%E4%B8%80%E8%BD%AE
name=第一轮

那你看到的就不是 name=%E7%AC%AC%E4%B8%80%E8%BD%AE
name=第一轮

,这你都能解析出来,太猛了,昨天我没用json,今天寻思用json传,我开始想多了,我以为得用json_decode解析出来然后输出呢

那是你自己弄混了,datatype: "json", 说的是返回的结果按 json 解析
所以你也不能简单的 echo $_POST['name']; 了事

那你看到的就不是 name=%E7%AC%AC%E4%B8%80%E8%BD%AE
name=第一轮

方便加QQ么,加下QQ以后有问题直接问你,你比CSDN权威啊!!!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template