Ошибка:
latlng is undefined(var lng = latlng.lng(); )
Хотя он получает значение и помещается в текстовые поля
нет ответа от AJAX. Я хочу ответ в виде текста, а не XML. Чего мне не хватает?
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
//map.addControl(new GMap2TypeControl());
map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
GEvent.addListener(map, "click", function(overlay, latlng) {
var inputForm = document.createElement("form");
inputForm.setAttribute("action","");
inputForm.onsubmit = function() {storeMarker(); return false;};
//retrieve the longitude and lattitude of the click point
var lng = latlng.lng();
var lat = latlng.lat();
inputForm.innerHTML = '<fieldset style="width:150px;">'
+ '<legend><b>Add Property<b></legend>'
+ '<label for="name"><B>Name</b></label>'
+ '<input type="text" id="name" style="width:100%;"/>'
+ '<label for="address"><b>Address</b></label>'
+ '<input type="text" id="address" style="width:100%;"/>'
+ '<label for="address"><b>Type</b></label>'
+'<select id="type"><option>Homes</option><option>Plots</option><option>Commercials</option></select>'
+ '<label for="address"><b>Prperty Type</b></label>'
+'<select id="property_type"><option>Sale</option><option>Rent</option><option>Wanted</option></select>'
+ '<label for="address"><b>Descreption</b></label>'
+ '<textarea id="description" cols="15" rows="4" name="description"></textarea>'
+ '<input type="text" id="longitude" value="' + lng + '"/>'
+ '<input type="text" id="latitude" value="' + lat + '"/>'
+ '<input type="submit" value="ADD"/>'
+ '</fieldset>';
map.openInfoWindow (latlng,inputForm);
});
}
}
Вот функция маркера магазина:
function storeMarker(){
//alert("xainee");
var lng = document.getElementById("longitude").value; //getting the longitude
var lat = document.getElementById("latitude").value;//getting the latitude
alert(lng +"and"+lat);
//geeting the user data in form
var getVars = "storeMarker.php?name=" + document.getElementById("name").value
+ "&address=" + document.getElementById("address").value
+ "&description=" + document.getElementById("description").value
+ "&property_type=" + document.getElementById("property_type").value
+ "&type=" + document.getElementById("type").value
+ "&lng=" + lng
+ "&lat=" + lat ;
//alert(getVars);
//////////////////////////////////////////
var Request = false;
if (window.XMLHttpRequest) {
Request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
Request = new ActiveXObject("Microsoft.XMLHTTP");
}
if (Request) {
alert("workinh");
Request.open("GET","storeMarker.php"+getVars,true);
Request.onreadystatechange=function()
{
if (Request.readyState==4 && Request.status==200)
{
document.write(responseText);
}
}
Request.send(null);
}
}
А вот страница storeMarker.php
:
<?php
include_once('clsGeneral.php');
echo $name=$_GET['name'];
echo $address=$_GET['address'];
echo $type=$_GET['type'];
echo $property_type=$_GET['property_type'];
echo $descreption=$_GET['description'];
echo $lat=(float)$_GET['lat'];
echo $lan=(float)$_GET['lng'];
$my_query="INSERT INTO map_marker SET name='$name',
address='$address',type='$type',property_address='$property_type',
descreption='$descreption',lat='$lat',lan='$lat'";
db_execute($my_query);
?>
Моя проблема заключается в том, что, когда Geventlistner
запускается при щелчке, отображается всплывающее окно, показывающее все элементы со значениями широты и долготы в текстовых полях, но когда я щелкаю в любом текстовом поле, появляется сообщение об ошибке «Латлан не определен». Во-вторых, это не отправка запроса и, например, отправка, а не ответа, я хочу получить ответ в строке, а не в XML.