我发送了一个json请求到此网址https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=213471&format=json
在Chrome的开发者控制台中,我从我访问的JSON文件中收到此错误:
Uncaught SyntaxError:意外的令牌:
我做错了什么或者json代码错了吗?
如何绕过这个?
function go () {
send("https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation? stopid=213471&format=json&callback=processData");
}
function send(url) {
var script = document.createElement('script');
script.setAttribute('src', url );
var head = document.getElementsByTagName('head')[0];
head.appendChild(script);
}
function processData (data) {
var dueTimes = document.getElementsByTagName('results')[0];
var result = document.getElementsByTagName('result');
var time = document.getElementsByTagName('duetime');
var one = dueTimes.result[0].time;
var two = dueTimes.result[1].time;
document.getElementById("times").innerHTML = "Due: " + one + "Second: " + two;
}
window.onload = go;