i can't find a reference to marker
anywhere in your code.
so try
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(html);
infowindow.open(map, this); //this refers to the marker that is clicked
});
if you have a variabe var marker
which refers to a valid marker like
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
map:map
});
then your code will work, if there is no scope issues. it's not needed since this
will work fine