Home > Backend Development > PHP Tutorial > javascript - php js interactive data

javascript - php js interactive data

WBOY
Release: 2016-08-04 09:20:23
Original
1758 people have browsed it

<code>$.get('/path/to/file', function(data) {

        if(data){
            //将数据塞到你的相应的dom节点中就OK了
        }
    /});</code>
Copy after login
Copy after login

I want to ask: does this data require php return $data or echo $data? I tried it myself but it didn’t work...

Reply content:

<code>$.get('/path/to/file', function(data) {

        if(data){
            //将数据塞到你的相应的dom节点中就OK了
        }
    /});</code>
Copy after login
Copy after login

I want to ask: does this data require php return $data or echo $data? I tried it myself but it didn’t work...

echo
1 There are generally 3 formats: json, text, xml. According to your corresponding situation, the corresponding format data is output $.get(url, function (result set object) {}, 'format')
2 I feel like you don't understand this principle very well. . For example, how do you judge whether it is a pornographic website?
1 Access the target address
2 The server has done a series of business logic
3 Display it
4 Your eyes see it and tell your brain 5 You know what you will do next
ajax The data here is your eyes , return is only step 2, and echo is step 3. You can only see your data object after it is displayed, and then you can use data

Return and echo (print_r, etc.) can be used, but the order is to output the return data first, and then output the echo content from top to bottom

<code>    $.get(url,function(data){
    });</code>
Copy after login

Test whether there is any problem with your url

To be able to return a string
you should use echo

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