How php receives json
$.ajax({ cache: true, type: "POST", url:"/index.php/Article/index", data:{name:$("#name").val()}, async: false, datatype: "json", error: function(request) { alert("Connection error"); }, success: function(data) { } });
Firebug: name = % E7 % AC % E4 % B8 % 80% E8 % BD % AE. I want to know how to get the name in the php background, and output to the foreground page
Reply to discussion (solution)
Echo $ _ POST ['name'];
Echo $ _ POST ['name'];
The output is NULL or I don't need to post any more ..
What you see is not name = % E7 % AC % E4 % B8 % 80% E8 % BD % AE
Name = first round
What you see is not name = % E7 % AC % E4 % B8 % 80% E8 % BD % AE
Name = first round
You can parse it all. it's so fierce. yesterday I didn't use json. today I tried to use json for transmission. I started to think too much. I thought I had to parse it with json_decode and then output it.
You can mix it yourself. datatype: "json" indicates that the returned results are parsed in json format.
So you cannot simply echo $ _ POST ['name '];
What you see is not name = % E7 % AC % E4 % B8 % 80% E8 % BD % AE
Name = first round
Is it easy to add QQ? if you have any questions after adding QQ, ask you directly. you are more authoritative than CSDN !!!