Javascript-phpjs interaction data

Source: Internet
Author: User
{Code...}: does the data require phpreturn $ data or echo $ data...
$. Get ('/path/to/file', function (data) {if (data) {// plug the data into your corresponding dom node }/});

I want to ask: does this data require php return $ data or echo $ data? I tried to solve this problem myself...

Reply content:
$. Get ('/path/to/file', function (data) {if (data) {// plug the data into your corresponding dom node }/});

I want to ask: does this data require php return $ data or echo $ data? I tried to solve this problem myself...

Echo
1. the json, text, and xml formats output the corresponding format data according to your situation $. get (url, function (result set object) {}, 'format ')
2. you do not quite understand this principle. For example, how do you determine whether a website is a yellow website.
1. access the target address
2. the server has completed a series of business logic
3.
4. your eyes show and tell your brain 5. You know what you are doing next.
Ajax data here is your eyes, return is only step 1, echo is step 2, only show your data object can be seen, then you can use data

Both return and echo (print_r) are acceptable, but the order is to output the return data first, and then output the echo content from top to bottom.

    $.get(url,function(data){    });

Test whether your url is correct.

Returns a string.
Echo should be used

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.