I'm trying to use file_get_contents on loop, in order to fetch JSON string from an URL continuously (every second). And i need to store the result into a javascript variable. Here was my approach, but i didn't get any result from this. My page showed me nothing but endless loading.
<?php
set_time_limit(0);
while(true)
{
$jsonContent=file_get_contents('http://megarkarsa.com/gpsjson.php');
echo $jsonContent;
sleep(10);
}
?>
And here my javascript code.
setInterval(function(){
var jsonUpdPostData = <?php echo $jsonContent; ?>;
}, 100);
What should i do to make it work? Any suggestion will be appreciated.