0

I'm having some issues displaying the list of articles on my marker. I've definitely managed to get it to work and display things inside, but I think there's an issue with the syntax on my jquery

    var articles = "Test";
var param = {geo: place.postal_code};

$.getJSON("/articles", param)
.done(function(data,textStatus, jqXHR) {
    articles = data;
})

var infowindow = new google.maps.InfoWindow({
    content: articles
});

As far as I can tell, the getJSON is working properly, but am I misunderstanding what is being returned by data? This code is supposed to return the list of articles per the spec, but right now my marker only displays "Test"

After a long bit of thinking I've rewritten my code like so:

    $.getJSON("/articles", param, function(article) {
    for (link in article)
    {
        articles = article
        window.alert(articles)
        var infowindow = new google.maps.InfoWindow({
        content: articles
        });
    }

After using window.alert to debug, I'm almost sure that articles has the object, but I'm somehow parsing the data incorrectly. Right now I'm simply returning "0" which seems to be part of the obj, but somehow I can't get my key pairings correct

0

Turns out the issue was nothing to do with Jquery, but rather how i was attempting to interact with my objects.

articles = []
for (link in article[0])
{
    articles[link] = article[0][link].link;
}

works fine

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .