1

This is my code:

marker.addListener('click', function(){ 

    var content = "";

    var query = {geo: place.place_name};

    $.getJSON("articles.php", query)
    .done(function(data, textStatus, jqXHR){

        if(data != [])
        {   
            content += "<ul>";
            for(var i = 0; i < data.length; i++)
            {
                content += "<li><a href=\"" + data[i].link + "\" target=\"_blank\">" + data[i].title + "</a></li>";   
            }
            content += "</ul>";
        }

        else 
        {
            content += "No articles for this area";
        }

    })
    .fail(function(jqXHR, textStatus, errorThrown) {

        // log error to browser's console
        console.log(errorThrown.toString());
    });

    showInfo(marker, content);
});

If I click on a marker and check the Network the request seems fine and the link works if I put it directly into the browser. There aren't any console error and I tried different solutions but I keep getting a white infoWindow. I can't figured out what I'm I doing wrong!

Thanks!

1 Answer 1

1

When you first click the marker, the .done() function hasn't delivered your JSON data yet, thus content will still be "" when you call showInfo(marker, content); at the very end.

Try to move showInfo(marker, content); inside your .done() function, as the last command to be executed inside it.

If this solves your problem, please click the check button to accept the answer.

1

You must log in to answer this question.

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