0

Please help me figure out how $.getJSON works! I've tried to model my code off of the other $.getJSONs in the distro code but I cannot make it work. No matter how I try to implement this section of code it locks up addMarker and only 1 pin appears on my map. I know that the rest of my code works fine and that as soon as I can pull the JSON data this will work. I just can't figure out .$getJSON. Please help! Below is my code:

// array to enter headlines into
var articles = "<ul>";

var parameters = {
    geo: place.postal_code
};

// gets RSS feeds and prints out linked headlines
$.getJSON("articles.php", parameters)
.done(function(data, textStatus, jqXHR) {

    // add news healines to infowindow
    for (var i = 0; i < data.length; i++){
        articles += "<li><a href=\"" + data[i].link + "\">" + data[i].title + "</a></li>";
    }       
})
.fail(function(jqXHR, textStatus, errorThrown) {

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

// finish HTML unordered list
articles += "</ul>";

2 Answers 2

1

I figured out the problem. When defining parameters you need set geo to place.place_name not place.postal_code. For whatever reason place.postal_code totally breaks the function.

I imagine it's because geo needs to be a string passed into articles.php and postal_code is an integer. Postal_code may work if you convert it to a string.

0

The specification actually tell us to use AJAX

1

You must log in to answer this question.

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