【发布时间】:2015-10-04 04:11:14
【问题描述】:
首先,我使用谷歌地图和我使用 tomcat 我想要做的是,当我点击地图时,我会放置一个标记并 同时 y 发送点的纬度和经度
这是我的代码:
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
google.maps.event.addListener(map, 'click', function(event)
{
placeMarker(event.latLng);
$.ajax({
url: 'insertPoint.java',
type: 'POST',
data: {lat:latitud, lon:longitud},
dataType: 'json',
cache: false
})
.done(function(mensaje) {
document.write("success");
})
.error(function(mensaje) {
document.write("error");
});
});
}
但我不知道为什么我总是出错。 如果您需要其他内容,我将编辑帖子并发布你们需要的内容
谢谢
PD:我也尝试将 url 行更改为:
url: 'insertPoint',
【问题讨论】:
-
您检查浏览器控制台是否有任何错误报告?
-
就像控制台选项卡一样,您在网络选项卡中看到的内容与您触发的 url 相对...这将回答您的查询。
-
send the lat and long of the point- 你觉得你是怎么做到的?{lat:latitud, lon:longitud}- 什么是纬度和经度? -
但我不知道为什么我总是出错而你却说0个错误报告
-
Jaromanda X 因为如果 ajax 不发送信息,我会做一个 document.write,如果它发送它,它会说成功,纬度和经度是变量
标签: javascript jquery ajax google-maps