How php receives json

Source: Internet
Author: User
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 !!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.