Here at the last pset, I run into the first time I had to post a question (instead of just browsing other questions' answers).
I have clickable markers, but content
never fills in. When a marker is clicked, an empty infoWindow appears.
marker.addListener('click', function(){
var content = "";
// pull articles
var parameters = {geo: place.postal_code}
$.getJSON("articles.php", parameters)
.done(function(data, textStatus, jqXHR) {
// if there are any articles
// add items in data to list
// else, set content default message
})
.fail(function(jqXHR, textStatus, errorThrown) {
// log error to browser's console
console.log(errorThrown.toString());
});
showInfo(marker, content);
});
Am I failing to return content
so showInfo
can access it?
I've tried the recommendations from $.getJSON and $.ajax not working and $.getJSON in PSET8 mashup's addMarker function in scripts.js and addMarker pset8 mashup JSON not returning data, and none of them worked.
Thanks.
content += "<li><a href=" + data[i].link + " target=\"_blank\">" + data[i].title + "</a></li>";
to usecontent += "<li><a href= \"" + data[i].link + "\" target=\"_blank\">" + data[i].title + "</a></li>";
and let me know?$.getJSON
.done
function is not executing at all, because however I setvar content =
at the very top is what appears in the infoWindow. So expecting.fail
, I looked at the console for an error message, but nothing shows up there either. @ChrisG.done(function(data, textStatus, jqXHR)
to just.done(function(data)
?window.alert(content);
inside the if condition of.done
part? Also one add awindow.alert("Got inside done!");
write inside the.done
part to see if it really executes.