I load
http://search.twitter.com/search.json?callback=formatTweets&q=somehashTag×tamp="+new Date().getTime();
我突然得到
Error: illegal character
Source File: http://search.twitter.com/search.json?callback=formatTweets&q=sunshine×tamp=1305631097599
Line: 1, Column: 13
Source Code:
formatTweets(�
因为推特给我发了一条失败鲸鱼。
你能想出一种方法来检测和处理这个问题吗?
这是我的调用:
function loadTweets() {
var head = document.getElementsByTagName('head');
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "http://search.twitter.com/search.json?callback=formatTweets&q="+hashTag+"×tamp="+new Date().getTime();
head[0].appendChild(script);
}
我找到了这个question https://stackoverflow.com/q/19173/210774其中有一些有趣的答案。总而言之,一种方法是将服务器返回的所有错误包装在 JSON 中,另一种方法是提供一个链接 http://code.google.com/p/jquery-jsonp/对 jQuery 的 JSONP 实现进行了漂亮的重新解释。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)