javascript - php js interactive data

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

$.get('/path/to/file', function(data) { if(data){ //将数据塞到你的相应的dom节点中就OK了 } /});
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:

$.get('/path/to/file', function(data) { if(data){ //将数据塞到你的相应的dom节点中就OK了 } /});
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

 $.get(url,function(data){ });
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!