在我的代码中,我有:
$.ajax({
url: 'http://chapters.zmgc.net',
dataType: 'jsonp',
success: function(d){ // "Type","Name","Link","Contact","Location","Icon"
Tabzilla.zgContacts = d;
var countries = [];
d.rows.forEach(function(row){
if (row[0] == 'Country') countries.push(
{link:row[2], contact:row[3], country: row[4]}
);
});
但我收到一个错误,Uncaught SyntaxError: Unexpected token :
{
"kind": "fusiontables#sqlresponse",
....
如果我用实际文件替换 url 并删除 dataType,一切都按预期工作!
我已经在http://jsonlint.com/验证了http://chapters.zmgc.net的输出,没关系。
查看从http://chapters.zmgc.net返回的响应标头,它是:
Connection:keep-alive
Content-Type:application/json
Date:Thu, 13 Dec 2012 17:02:27 GMT
Transfer-Encoding:chunked
这是代码https://github.com/tomarcafe/Z-Tabzilla/blob/gh-pages/z-tabzilla.js#L282我想用读取远程数据替换本地文件?
我错过了什么?