Twitter 搜索 API - 网络错误:405 方法不允许
我正在关注本教程,了解如何使用 jquery 解析 twitter 搜索 api 请求。
http://webhole.net/2009/11/ 28/how-to-read-json-with-javascript/
帖子中的代码使用搜索框供用户输入搜索词,我只想删除搜索部分,因为我知道我要搜索的#tag 为了:
<div id="results"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var url='http://search.twitter.com/search.json?q=';
var query='%23HASHTAGOFMYCHOOSING';
var options='&result_type=recent&count=5';
$.getJSON(url+query+options,function(json){
$.each(json.results,function(i,tweet){
$("#results").append('<p><img src="'+tweet.profile_image_url+'" width="48" height="48" />'+tweet.text+'</p>');
});
});
});
我在 Firebug 中遇到的错误是 NetworkError: 405 Method Not Allowed
我只是想知道是否有人能解释一下我为什么破坏了这段代码。
谢谢,
I was following this tutorial on how to parse twitter search api requests with jquery.
http://webhole.net/2009/11/28/how-to-read-json-with-javascript/
The code in the post uses a search box for the user to enter the search term and what I simply wanted to do was remove the search part since I know the #tag that I want to search for:
<div id="results"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var url='http://search.twitter.com/search.json?q=';
var query='%23HASHTAGOFMYCHOOSING';
var options='&result_type=recent&count=5';
$.getJSON(url+query+options,function(json){
$.each(json.results,function(i,tweet){
$("#results").append('<p><img src="'+tweet.profile_image_url+'" width="48" height="48" />'+tweet.text+'</p>');
});
});
});
The error I am getting in Firebug is NetworkError: 405 Method Not Allowed
and I was just wondering if anyone could shine some light as to why I've broken this code.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,问题是我缺少
callback
参数,因此options
变量应如下所示:ah, the problem was that I was missing the
callback
parameter so theoptions
variable should read as follows: