【发布时间】:2012-09-17 01:48:42
【问题描述】:
我会因此掉头发 我已经构建了一个在 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's [link] 但我想使用我的原始代码,我目前使用的是 Cordova 2.0.0 和 Visual Studio 上的 Windows Phone sdk 7.1
【问题讨论】:
-
我在不久前的一次谈话中演示了一个 WP7 PhoneGap Twitter 搜索应用程序。源代码可在此处获得:scottlogic.co.uk/blog/colin/2012/02/… - 这可能会对您有所帮助。
-
我会跟着你哈哈
标签: jquery ajax windows-phone-7 cordova cordova-2.0.0