My code
// do ajax request and get JSON response
for (var i = 0; i < data.results.length; i++) {
result = data.results[i];
// do stuff and c
try this one
var marker = new Array();
for (var i = 0; i < data.results.length; i++) {
result = data.results[i];
// do stuff and create google maps marker
marker[i] = new google.maps.Marker({
position: new google.maps.LatLng(result.lat, result.lng),
map: map,
id: result.id
});
google.maps.event.addListener(marker[i], 'click', example(marker[i].id));
}
create new function
function example(my_window){
return function(){
createWindow(my_window);
}
}