1

Can anyone tell me what's wrong with my code? It seems like a simple debug test with console.log() isn't even executing properly:

function addMarker(place)       
{

    $.getJSON(Flask.url_for("articles"))
       .done(function(news){
         console.log("Test Success");

        var coordinates = {lat: parseFloat(places.latitude), lng: parseFloat(places.longitude)};

        markers = new google.maps.Marker({
            position : coordinates,
            map: map
        });

        markers.addListener('click', function() {
            showInfo(marker, news.title)                  
        });


      })
       .fail(function(){
         console.log("Error");
      });
}

Thanks in advance

2

You told the program to "get" info from "articles" here $.getJSON(Flask.url_for("articles")) but you didn't tell it what to GET. Assuming your articles function returns data as per the examples (eg https://ide50-username.cs50.io/articles?geo=02138), you need to send a "query string" to articles.

Use the supplied search function as a guide:

function search(query, syncResults, asyncResults)
{
    // get places matching query (asynchronously)
    var parameters = {
        q: query
    };
    $.getJSON(Flask.url_for("search"), parameters)

This places.latitude looks like a problem too. The argument to the function is singular.

When browser encounters a js error, it usually just stops executing.

| improve this answer | |

You must log in to answer this question.

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