I have a very waried error, and I don't now how to solve it. I have crossed around, searched for the same problem, tried to implement other appoaches, but nothing couldn't help me.

This is my code:

function addMarker(place)

var myLatlng = new google.maps.LatLng(place.latitude,place.longitude);

var marker = new google.maps.Marker({
    position: myLatlng,
    m_content: "geo="+ place.place_name
    //title: place.place_name

// show array of markers on the map
  for (var i = 0; i < markers.length; i++) {


google.maps.event.addListener ( marker,'click', function() {
$.getJSON( "articles.php",{geo: marker.m_content}) // postal_code

    if (data.length === 0)
        showInfo(marker, "No news today :(");

        var content = "<ul>";

        // template for ul
        var template = _.template("<li><a href'<%- link %>' target='_blank'>'<%- title %>'</a></li>");

        // iterate through the news
       for (var i = 0; i < data.length; i++)
       content+= template({link: data[i].link, title: data[i].title});

        // close list
        content+= "</ul>";

        // show infowindow
        showInfo(marker, content);
    .fail(function(data, textStatus, errorThrown) {

// put markers into array, which will be deleted

News are not appearing in the infoWindow, in log I can see that Im getting JSON object, but by some reason that objext is not parsed. I have tried to access to link and title like: data[i].title datat[i].link but it didn't help.

Can somebody help to me solve this issue.

Im getting such error:

SyntaxError: Unexpected token g in JSON at position 0 at JSON.parse () at m.parseJSON (jquery-1.11.3.min.js:5) at Pb (jquery-1.11.3.min.js:5) at x (jquery-1.11.3.min.js:5) at XMLHttpRequest.b (jquery-1.11.3.min.js:5)

Thank you in advance!

2 Answers 2


I found the reason finally!

Issue in articles.php file, by some reason was added these printf:




Because of that JSON object has had such additional strings:

geo<br />
<b>Notice</b>:  Array to string conversion in <b>/home/ubuntu/workspace/pset8/public/articles.php</b> on line <b>14</b><br />

that is why by JSON object was parsed as a string and always was put into .fail method. Actually this error is quite weird and not clear, and I have killed a lot of time to find it.


Just replace m_content: "geo="+ place.place_name with place.place_name.

You must log in to answer this question.

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