Android 使用CORS/jQuery mobile/phonegap获取RSS提要

Android 使用CORS/jQuery mobile/phonegap获取RSS提要,android,jquery-mobile,cordova,rss,Android,Jquery Mobile,Cordova,Rss,我正在尝试向我用Phonegap制作的应用程序添加RSS提要。导入提要时遇到问题,请求的资源上存在“No‘Access Control Allow Origin’头。”错误。这是否意味着我已正确设置了所有内容,但由于服务器不支持,我无法获取它?最终,我希望rss提要是一个谷歌日历事件列表,那么这就是我应该如何处理这个问题的方式吗?下面是我的get函数代码 get_blog_data: function(){ var app = this; $.ajax({

我正在尝试向我用Phonegap制作的应用程序添加RSS提要。导入提要时遇到问题,请求的资源上存在“No‘Access Control Allow Origin’头。”错误。这是否意味着我已正确设置了所有内容,但由于服务器不支持,我无法获取它?最终,我希望rss提要是一个谷歌日历事件列表,那么这就是我应该如何处理这个问题的方式吗?下面是我的get函数代码

get_blog_data: function(){


    var app = this;
    $.ajax({

        // The 'type' property sets the HTTP method.
        // A value of 'PUT' or 'DELETE' will trigger a preflight request.
        type: 'GET',

        // The URL to make the request to.
        url: 'http://rss.cnn.com/rss/cnn_topstories.rss',

        // The 'contentType' property sets the 'Content-Type' header.
        // The JQuery default for this property is
        // 'application/x-www-form-urlencoded; charset=UTF-8', which does not trigger
        // a preflight. If you set this value to anything other than
        // application/x-www-form-urlencoded, multipart/form-data, or text/plain,
        // you will trigger a preflight request.
        contentType: 'text/plain',

        xhrFields: {
            // The 'xhrFields' property sets additional fields on the XMLHttpRequest.
            // This can be used to set the 'withCredentials' property.
            // Set the value to 'true' if you'd like to pass cookies to the server.
            // If this is enabled, your server must respond with the header
            // 'Access-Control-Allow-Credentials: true'.
            withCredentials: false
        },

        headers: {
            // Set any custom headers here.
            // If you set any non-simple headers, your server must include these
            // headers in the 'Access-Control-Allow-Headers' response header.
        },

        success: function(data) {
            // Here's where you handle a successful response.
            app.blogData = $(data).find("item").map(function(i,item){
                return {
                    title: $(item).find("title")/text(),
                    body: $(item).find("description").text()
                }
            }).toArray();
            $("#eventListPageContent").html(app.eventListTemplate(this.blogData));
            $("#eventListPageContent").listview().listview( "refresh" );
        },

        error: function() {
            // Here's where you handle an error response.
            // Note that if the error was due to a CORS issue,
            // this function will still fire, but there won't be any additional
            // information about the error.
            console.log("ERROR GETTING FEED");
            console.log($.support.cors);
        }
    });

},

CORS是web浏览器的一个限制,不允许您从给定页面向另一个域发出请求。这将阻止您从页面获取RSS提要

唯一的解决方法是使用类似的提要API,将RSS提要转换为JSON,然后通过JSONP进行查询