简体   繁体   中英

php file_get_contents with ajax content

I have used file_get_contents function to get content of a website. However it doesn't load the content that displayed in an Ajax. How can I get fully content after the ajax complete?

echo file_get_contents("thewebsiteurl");

I mean in the thewebsiteurl has an Ajax, and content ABC displayed after this ajax. When I use file_get_contents to get the content of the thewebsiteurl , I can not get the ABC content.

Thanks

It is not clear what you mean.

What I do get out of it is that you're trying to send data with Ajax. This data then needs to get processed in PHP.

Ajax automatically encode the data with JSON for you. This means that in you php code you should use

json_decode();

I hope this was the answer to your vague question.

If you are looking for content from different domain this will do the trick:

$.ajax({
    url:'http://www.corsproxy.com/' +
        'en.wikipedia.org/wiki/Briarcliff_Manor,_New_York',
        type:'GET',
        success: function(data){
           $('#content').html($(data).find('#firstHeading').html());
        }
});

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM