Php скрипт в javascript
Есть php-код
$user_api_key = ''; //GOOGLE API KEY if( $curl = curl_init() ) { curl_setopt($curl, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/geocode/json?address=' . str_replace(" ", "+", $name ) . '&key=' . $user_api_key); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); $json_responce = json_decode( curl_exec($curl) ); curl_close($curl); // Если результат успешный, парсим ответ if ( $json_responce->status == 'OK' ) { $lat_coord = $json_responce->results[0]->geometry->location->lat; $lat_coord = $json_responce->results[0]->geometry->location->lng; } echo 'Широта: ' . $lat_coord; echo ' Долгота' . $lat_coord; } Посылает запрос, получает json ответ и распарс происходит. Ну и запись данных в переменные. Как сделать точно такое же на js |
Цитата:
https://javascript.ru/ajax/intro Цитата:
http://javascript.ru/forum/css-html/...rsit-json.html |
Часовой пояс GMT +3, время: 08:20. |