首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用jQuery解析atom提要

无法使用jQuery解析atom提要
EN

Stack Overflow用户
提问于 2011-09-24 19:04:38
回答 1查看 596关注 0票数 0

我使用jFeed解析atom提要并尝试显示标题。我已经编写了成功和错误函数,但它既没有进入成功函数,也没有进入错误函数。

下面是我的代码。请让我知道下面的代码出了什么问题。

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> 
<script type="text/javascript" src="javascript/jquery.jfeed.js"></script>

<script type="text/javascript">

$(document).ready(function(){

//read the atom feed

$.getFeed({
    type:"GET",
    url:"http://www.google.co.in/trends/hottrends/atom/hourly",
    success:function(feed)
    {
        alert(feed.title);
    },
    error:function(error)
    {
        alert(error);
    }

});


});

</script>
</head>
<body>
<div id="content"></div>
</body>
</html>
EN

回答 1

Stack Overflow用户

发布于 2011-09-24 19:24:40

$.getFeed不接受“类型”和“错误”参数。

来自jfeed源代码:

代码语言:javascript
复制
jQuery.getFeed = function(options) {

options = jQuery.extend({

    url: null,
    data: null,
    success: null

}, options);

if(options.url) {

    $.ajax({
        type: 'GET',
        url: options.url,
        data: options.data,
        dataType: 'xml',
        success: function(xml) {
            var feed = new JFeed(xml);
            if(jQuery.isFunction(options.success)) options.success(feed);
        }
    });
}

所以你最有可能得到一个错误。

尝试发送一个简单的Ajax请求,看看您得到的是什么错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7538617

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档