基于webkit的浏览器将json解释为脚本 [英] webkit based browser interpretate the json as a script
问题描述
我只是试着通过js获取我的zootool项目,将它们推送到我博客的页脚中......但没有成功。
这里是使用
的代码(jquery框架)
im just tryin to get my zootool items via js to push them in my blog's footer...but with no success. here's the code im using (jquery framework)
jQuery(document).ready(function($)
{
//first try
var url = "http://zootool.com/api/users/items/?username=USER_NAME&apikey=API_KEY&jsonpcallback=?"
$.getJSON(url, function(data){ console.log(data); });
//second try
url2 = "http://zootool.com/api/users/items/?";
data = "username=USER_NAME&apikey=API_KEY";
$.ajax(
{
url: url2, dataType: 'jsonp', data: data,
success: function(data){ console.log(data); }
});
}
基于webkit的浏览器告诉我:
资源被解释为脚本但是用MIME传输类型application / json。
webkit based browser tells me that: "Resource interpreted as script but transferred with MIME type application/json."
firefox运行良好,我得到一个application / json; utf-8对象,我可以成功解析。
你知道吗可能是问题?
提前多多谢谢!
firefox works good, i get an application/json; utf-8 object that i can parse succesfully. do you know what could be the problem? thanks a lot in advance!
Luca
推荐答案
直接来自zootool的创建者:
directly from the creator of zootool:
api不支持jsonp的回调至今。我刚添加它们,所以你的第一个版本应该稍作调整。你必须将jsonpcallback重命名为callback以使其工作。看看这里:
the api hasn't supported callbacks for jsonp so far. I just added them so your first version should work with a little adjustment. you have to rename jsonpcallback to callback to make it work. take a look here:
这篇关于基于webkit的浏览器将json解释为脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!