I have been working on this since yesterday, and I am not sure if I am structuring my program correctly. When I call $.getJSON and simply print out the data it fetches, everything works fine, but I can't incorporate them into my infowindow (the window shows up, but with no content). I am doing this like so:
var infowindow = new google.maps.InfoWindow({
content: $.getJSON("articles.php", {geo: place.place_name})
.done(function(data, textStatus, jqXHR) {
// create an unordered list
var articles_list = "<ul>";
// populate bullet points with links -- just try title for now
for (i = 0; i < data.length; i++)
articles_list += "<li>" + data[i].title + "</li>";
articles_list += "</ul>";
})
.fail(function(jqXHR, textStatus, errorThrown) {
// log error to browser's console
console.log(errorThrown.toString());
})
});
Could someone help me figure out what I am doing wrong? My main worry is that I am not putting the $.getJSON statement in the right place. I have also tried creating a separate content variable, populating it with whatever $.getJSON returns, like so:
var windowContent = <use $.getJSON statement as above>
var infowindow = new google.maps.InfoWindow({
content: windowContent
});
but this didn't work either.
Any help will be much appreciated :)