I am currently experimenting JSONP data using native Javascript. I am trying to get the data to display. How ever i am receiving a syntax error. Unexpected token : As far as i am aware i follow the correct steps into in order gather data. Below is a snippet of my code. Link to JSfiddle
<script src="http://linkToMyJSONDetails"></script>
JS
function (data) {
var showStops = '';
for (var i = 0; i < data.markers.length; i++) {
showStops += '<div class="stops">';
showStops += '<h3>' + data.markers[i].smsCode + '</h3>';
showStops += '<h1>' + data.markers[i].name + '</h1>';
showStops += '</div>';
}
document.getElementById('bus-stops').innerHTML = showStops;
}
function (data)You need to give a name to the function. Also where are you calling this function? Just by adding the<script>add you can't access it using JavaScript.