gpt4 book ai didi

javascript - 如何从infowindow获取到mysql

转载 作者:行者123 更新时间:2023-11-29 23:45:41 25 4
gpt4 key购买 nike

我正在尝试从 infowindow 获取变量到 mysql。

我在信息窗口中有 3 个链接

1-callto2 封邮件3-网页访问

downloadUrl("gen_xml.php", function(data) {
var xml = parseXml(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var nombre = markers[i].getAttribute("nombre");
var empresa = markers[i].getAttribute("empresa");
var address = markers[i].getAttribute("address");
var web = markers[i].getAttribute("web");
var telefono = markers[i].getAttribute("telefono");
var emailcontact = markers[i].getAttribute("emailcontact");

var html ="<div class='infobas'><div><a href='https://mndesign.es' alt='mndesign' target='_blank'><img src='/img/mndesign_localizatuempleo.png' width='80' height='60' style='float:left;'></a></div><div><div><strong>Contacto: </strong>" + nombre + "</div><div><strong>Empresa: </strong>" + empresa + "</div></div></div><br><div><div>" + address + "</div></div><br><div><div id='botones'><a id='visitweb' class='visitweb' href='" +web+ "' target='_blank'><span style='background: url(/img/link.png) no-repeat 1px center; padding:2px 25px 2px 25px; width:20px; height:20px;'>Web</span></a><a id='tfno' class='tfno' onclick='saveData()' href='callto:0034" + telefono + "'><span style='background: url(/img/llamar.png) no-repeat 1px center; padding:2px 20px 2px 30px; width:20px; height:20px;'>Llamar</span></a><a id='correo' class='correo' href='mailto:" + emailcontact + "?&subject=CV a traves de www.localizatuempleo.com!&body=Estimad@ " + nombre + ": Le envio CV por oferta de empleo anunciada en localizatuempleo.com!'><span style='background: url(/img/cv.png) no-repeat 1px center; padding:2px 25px 2px 25px; width:20px; height:20px;'>Enviar CV</span></a></div>></div>";

var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
title: address +' / '+ ciudad,
icon: icon.icon
});

function bindInfoWindow(marker, map, infoBox, html) {
google.maps.event.addListener(marker, 'click', function() {
infoBox.setContent(html);
infoBox.open(map, marker);
infobox.draw(); // to redraw if infobox size changed
});

}

function saveData() {
var telefono = document.getElementById('tfno').getElementsByTagName('a').href;
var url = "dataWindow.php?href=" + telefono;

downloadUrl(url, function(data, responseCode) {
if (responseCode == 200 && data.length <= 1) {
//document.getElementById("tfno").innerHTML = "";
}
});
}

在我的信息窗口中:

<a id='tfno' class='tfno' onclick='saveData()' href='callto:0034" + telefono + "'><span style='background: url(/img/llamar.png) no-repeat 1px center; padding:2px 20px 2px 30px; width:20px; height:20px;'>Llamar</span></a>

我正在尝试获取href中的变量并将其传递给mysql,但是电话,这个案例是空的,我需要获取+telefono+。

其他 2 个变量也是如此。

如何获取这些变量?

感谢您提前提供的帮助

最佳答案

我解决了这个问题,只是我改变了函数 saveData ()

function saveData() {

var telefono=document.getElementById('tfno').getAttribute('title');

$.ajax({ url:"dataWindow.php", 类型:'POST', 数据:{电话:telefono}

});

}

并使用 getAttribute() 添加标题到我的链接

<a id='tfno' class='tfno' title='getAttribute()" + telefono + "' onclick='saveData()' href='callto:" + telefono + "'><span style='background: url(/img/llamar.png) no-repeat 1px center; padding:2px 20px 2px 30px; width:20px; height:20px;'>Llamar</span></a>

现在工作了,我的 mysql 中唯一的问题是 get getAttribute()111111111

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com