0

I have successfully implemented the event listener for add marker and am able to display strings when a marker is clicked. However, I cannot workout why my $.getJSON code that brings articles data is not working. An extract of my code is below (note, markers is what I have redefined place as).

I have tried both defining the geo as a parameter and the version below, a variant of which worked for a classmate in another question, but with no luck. The map loads without errors, but when a marker is clicked it always displays "Slow news day!" and never any articles. Thanks so much for any help.

var articles = "Slow news day";

$.getJSON("articles.php?geo="+markers.postal_code,function(data) {
        if (data !== null) {
            var articles = data;
        }
    });

1 Answer 1

1

I was struggling with this for quite some time - my code looked very similar to yours. I searched forever (since I didn't really know how to express my question) until I found this here: https://stackoverflow.com/questions/751218/how-to-use-getjson-sending-data-with-post-method

There you see that in the answer with only 10 votes {id: 287} is used, so I tried that for geo and it worked :)

 var parameters = { geo: query };
 $.getJSON("articles.php", parameters).done(function(data, textStatus, jqXHR) {
// create the article list
} 
3
  • Thanks again for your help - it worked! :) Commented Feb 24, 2015 at 8:35
  • where is this code located in script.js? What is query defined as?
    – Kohl
    Commented Mar 1, 2015 at 16:14
  • there is a similar code in script.js within the search function to start working with
    – Federico
    Commented Mar 4, 2015 at 0:51

You must log in to answer this question.

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