javascript - PHP file_get_contents from a page which uses jQuery innerHTML -


i have 2 files, 1 named location.php sourced here: http://jsfiddle.net/g25y68kb/ displays locations google map's api using innerhtml intend separate asterisk (*).

i trying put results page in php array, here have tried:

<?php $url = "location.php"; $lines = file_get_contents($url); print_r ( explode( '*', $lines ) ); ?> 

this returns:

array( [0] => ) 

however, when removing explode , using print_r($lines); returns correctly in jsfiddle above like:

emirates stadium, hornsey road, london, united kingdom*stadium residential, london, united kingdom*stadium near london, united kingdom*olympic stadium, london, united kingdom*fulham taxis/stadium car minicab services, fulham road, london, united kingdom*

although, when view source, can see javascript , not location values innerhtml, i'm guessing problem?

is there work around or better way this?

all js code interpreted in browser context, in memory of client machine. reason php code context in web server can't reach data.

you can set array results , pass php script via ajax this:

            var resultlist = [];             (var = 0, prediction; prediction = predictions[i]; i++) {                 results.innerhtml += prediction.description + '*';                 resultlist.push(prediction.description);             }              $.post( "test.php", { 'results': resultlist} ); 

in test.php can eval var $_post['results'] obtain json list.

or maybe can sugested @adeneo, automation framework headless browser phantomjs


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -