convert php file_get_contents & json code to javascript code

i have this code :

    $latf = 32.389664916420614;
$longf = 48.379170298576355;

$latt = 32.389664916420614;
$longt = 48.379170298576355;

$data = file_get_contents("http://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=$latf,$longf&destinations=$latt,$longt&language=en-EN&sensor=false");
$data = json_decode($data);
$time = 0;
$distance = 0;
foreach($data->rows[0]->elements as $road) {
    $time += $road->duration->value;
    $distance += $road->distance->value;
}


echo "from";
echo "<br/>";
echo "to ".$data->destination_addresses[0];
echo "<br/>";
$dd = $distance/1000;
echo "distance is";
?>

how convert this php code to javascript code?????????????????????????????

any tricks?
plz help ,

Read more here: convert php file_get_contents & json code to javascript code

Leave a Reply

Your email address will not be published. Required fields are marked *