[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Передача данных из php в js
Sergeiqwe93
Здравствуйте. Помогите пожалуйста. Имеется внешний скрипт php,
<?php
include "auth.php"; //Подключаем БД

$query = "select * from Organization_name where ID_Categories=".$_REQUEST['idcat']."";

$result = mysql_query($query) or die(mysql_error());

$arrsch=array(); //массив координат точек широты
$arrd=array(); //массив координат точек долготы

$i=0; //переменная счетчик

while ($row=mysql_fetch_array($result))
{
$arrsch[$i]=(float)$row['Сoordinates_r'];
$arrd[$i]=(float)$row['Сoordinates_l'];
$i++;

}
?>

как мне получить эти массивы точек в js для дальнейшего их использование. Большое спасибо за ваши ответы. просьба небольшой пример.
Sergeiqwe93
Вот js-скрипт:
<script>



function loadPoint(){
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +
'callback=inPoint';
document.body.appendChild(script);
}


function inPoint() {
var mapOptions = {
zoom: 15,
center: new google.maps.LatLng(53.682, 23.8260519)
};

var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var i=0;
var l=53.686;
var r=23.8260519;


while (i<длина массива){

i++;

var point1 = new google.maps.LatLng(l, r);
var marker = new google.maps.Marker({
position: point1, map: map, title: 'Пробная точка!'
});

}

$.ajax({
type: "POST",
url: "show.php",
data: "idcat="+$("#idcat").val(),
success: function(html){
$("#content").html(html);
}
}
);

}
window.onload = loadScript;

</
script>
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.