$.get('/path/to/file', function(data) { if(data){ //将数据塞到你的相应的dom节点中就OK了 } /});
I want to ask: does this data require php return $data or echo $data? I tried it myself but it didn’t work...
$.get('/path/to/file', function(data) { if(data){ //将数据塞到你的相应的dom节点中就OK了 } /});
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){ });
Test whether there is any problem with your url
To be able to return a string
you should use echo