问题是当我尝试使用此代码从tmi.twitch.tv api使用url:http://tmi.twitch.tv/hosts?include_logins=1&target=70219146获取日志时,我得到Systax Error Unexpected Token。代码是:
$(document).ready(function() {
$.getJSON("http://tmi.twitch.tv/hosts?include_logins=1&target=70219146&callback=?", function (data) {
console.log(data.hosts)
});
})
我可以使用php和json数组获取数据:
$json_array = json_decode(file_get_contents('http://tmi.twitch.tv/hosts?include_logins=1&target=70219146'), true);
echo $json_array['hosts']['0']['host_login']."</br>";
但是没有办法在html中使用这个吗?感谢