小编use*_*978的帖子

使用Phonegap应用程序执行ajax请求时出现问题

我正在尝试使用Phonegap和jQuery创建一个简单的RSS阅读器.我正在学习本教程:http://visualrinse.com/2008/09/24/how-to-build-a-simple-rss-reader-with-jquery/.

当我在浏览器中试用代码时,我已经设法让这个工作正常.php文件获取feed并输出它就像我期望的那样.但是当我从我编译的Phonegap应用程序中运行相同的文件时,ajax-request只返回php文件的内容(php代码,而不是执行结果).

我花了几个小时谷歌搜索这个并尝试了很多教程和调整.我在官方的Phonegap论坛上找不到任何解决方案.我究竟做错了什么?问题似乎是PHP没有响应请求.我试图将php文件移动到另一个域但结果是一样的,它可以在我的浏览器中运行但不在编译的应用程序中.

这是启动ajax代码的jQuery代码:

function get_rss_feed() {
    //clear the content in the div for the next feed.
    $("#feed_content").empty().html('<img class="loader" src="js/images/ajax-loader.gif" alt=""/>');

    $.ajax({
        url: 'http://192.168.1.7/rssApp/www/rss-proxy.php?url=http://www.nytimes.com/services/xml/rss/nyt/GlobalHome.xml',
        success: function parseRSS(d) {

        //find each 'item' in the file and parse it
        $(d).find('item').each(function() {

            //name the current found item this for this particular loop run
            var $item = $(this);
            // grab the post title
            var title = $item.find('title').text();
            // grab the post's URL
            var link = $item.find('link').text();
            // …
Run Code Online (Sandbox Code Playgroud)

php ajax rss jquery cordova

7
推荐指数
1
解决办法
6994
查看次数

标签 统计

ajax ×1

cordova ×1

jquery ×1

php ×1

rss ×1