
Pasar variables con .load
Publicado por miguel (2 intervenciones) el 01/09/2014 21:18:01
Hola, soy novato en esto de Jquery y estoy peleando para adaptar un codigo a un mapa de google. La cosa es que logro ubicar resultados en un mapa de google y luego quiero que ese link/resultado que se genera me actualice cierta info en un <div> y aqui esta el error, no logro pasar la variable php para que el div me reciba. Si escribo este numero Literalmente digamos, funciona perfecto, no así si intento con una variable. Copio el codigo completo a ver si me dan un amano. Gracias!
LES DEJO EL LINK PARA QUE LO VEAN http://www.dpo.gov.ar/mapas/mapadeobrasenejecucion2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//codigo del maps de google
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var customIcons = {
1: {
icon: 'images/educacionE.png'
},
2: {
icon: 'images/saludE.png'
},
3: {
icon: 'images/seguridadE.png'
},
4: {
icon: 'images/administracionE.png'
},
5: {
icon: 'images/equipamientoE.png'
},
6: {
icon: 'images/socialE.png'
},
7: {
icon: 'images/cultoE.png'
},
8: {
icon: 'images/planificacionE.png'
},
9: {
icon: 'images/culturaE.png'
}
};
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(-28.945669, -57.903442),
zoom: 7,
mapTypeId: 'terrain'
});
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl("phpsqlajax_genxml3e.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var NombreObra = markers[i].getAttribute("NombreObra");
var IdOb = markers[i].getAttribute("IdObras"); // ESTA ES LA VAR QUE NECESITO LLEVAR AL DIV
var id = markers[i].getAttribute("id");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = "<table width=260px><tr><td width=90px><img src=images/fotitos/" + id + ".jpg width=90 height=60></td><td width=170px><a href=# onclick='cargar();'>" + name + "</a><br>" + address +"</td></tr></table>";
//ESTE ES EL LINK QUE ME LLEVA AL DIV Y QUE MANDA LA VARIABLE
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]>
function cargar() // ESTA ES LA FUNCION QUE ENVIA LA VAR
{
$('#central').load('detalleiteva.php?IdObras=', {IdObras: 750}); // EL NUM DEBERIA SER REEMPLAZADO POR LA VAR.
}
</script>
LES DEJO EL LINK PARA QUE LO VEAN http://www.dpo.gov.ar/mapas/mapadeobrasenejecucion2.php
Valora esta pregunta


0