0

我将失去头发,因为我已经构建了一个在 IOS 和 Android 上运行良好但所有 ajax 调用都失败的简单应用程序我尝试了很多 mojo jojo 技巧,不同版本的cordova,但没有任何帮助

我的代码看起来像

$("#twitter").live('pageshow', function() {

    // Empty the list of recorded tracks
    $("#tweets_list").empty();


    var tmpTweet = "";

    //regex for urls
    var output = $("#tweets_list");
    $.ajax({
        url: "http://twitter.com/status/user_timeline/mysecretathens.json?count=20&_nocache=" + cacheBuster,

        jsonp: 'jsoncallback',
        timeout: 5000,
        beforeSend: function() {
            $('#loader').show();
        },
        complete: function() {
            $('#loader').hide();
        },
        success: function(data, status) {
            $.each(data, function(i, item) {
                var tmpTweet = item.text;
                //replace links
                tmpTweet = item.text.replace(/(http:\/\/\S+)/g, "<a href='$1'>$1</a>");

                var singleTweet = "<li class='twitter-feed'>" + item.text + "</li>";

                output.append(singleTweet).listview('refresh');
            });
        },
        error: function() {
            output.text('There was an error loading the data.');
        }
    });
    $("#tweets_list").listview('refresh');



});​

我已放置 S.support.cors= true; 和 $.mobile.allowCrossDomainPages= true 还尝试了其他一些技巧

唯一有效的方法是 Simon 的[link] 但我想使用我的原始代码,我目前在 Visual Studio 上使用 Cordova 2.0.0 和 windows phone sdk 7.1

4

1 回答 1

0

几个问题:

  1. 您是否确认您从 AJAX 调用中得到了什么错误?(例如,使用 Fiddler 检查响应)

  2. 您是否确认 JqueryMobile mobileinit 事件正在触发?一个简单的 console.log 就足够了。您指定脚本标签的顺序非常重要。看到这个帖子。 如何在 jQuery Mobile 中绑定“mobileinit”事件?

于 2012-10-01T08:29:13.233 回答