我有一个事件,当我点击标记google.maps.event.addListener(marker, 'rightclick', (function (marker) {
上的右键时,它会返回该代码中的函数 return function () { marker.setMap(null); delete markerBusyBrID[this.marker]; deleteBrigade(); //As I think I need something here to start my ajax query }
我需要向ajax发送请求
这是代码的一部分:
google.maps.event.addListener(marker, 'rightclick', (function (marker) {
return function () {
marker.setMap(null);
delete markerBusyBrID[this.marker];
deleteBrigade();
//here must be start of my ajax query
}
我的servlet名称getChangeBrigadeStatus
和我需要发送的参数brigadeNumber
我不明白如何发送ajax查询。
答案 0 :(得分:0)
我真的不明白,但如果你想要的是在完成某些功能之后做出的ajax请求,你可以尝试这样的事情
只有在触发所有功能时才会发送请求
当然,您可以添加参数并根据需要修改sendTheRequest()
,希望有所帮助
var fs = [];
function sendTheRequest(){
if (fs.length == 2) {
fs = [];
//send it
}
}
function fun1(){
//code
fs[0] = 1;
sendTheRequest();
}
function fun2(){
//code
fs[1] = 1;
sendTheRequest();
}
答案 1 :(得分:0)
创建一个名为deleteBrigade
的函数,并将其用于两个点
// this function will be reused for the click event handler
// and also for being executed at the end, inside your google maps event right click handler
function deleteBrigade() {
if(!allBrigadeNumbers.length==0){
var brigadeNumber = allBrigadeNumbers[allBrigadeNumbers.length-1];
}
$.get('getChangeBrigadeStatus', {brigadeNumber: brigadeNumber}, function () {
// something here
});
}
$(document).ready(function () {
$('#deleteBrigadeButton').click(deleteBrigade);
});
//... wherever this is
google.maps.event.addListener(marker, 'rightclick', (function (marker) {
return function () {
marker.setMap(null);
delete markerBusyBrID[this.marker];
deleteBrigade();
}
})
答案 2 :(得分:0)
直到我等待答案并帮助我查看其他主题。一个新主题让我想到答案,这很容易。
这是一个代码:
google.maps.event.addListener(marker, 'rightclick', (function (marker) {
return function () {
marker.setMap(null);
delete markerBusyBrID[this.marker];
deleteBrigade();
$.get('getChangeBrigadeStatusFreeFromBrigade', {brigadeNumber: brigadeNumber}, function () {
});
但是这段代码可以帮助我处理其他我也不知道如何解决的问题