1
我試圖從Facebook閱讀基本的牆壁信息,並顯示在查詢移動列表。該代碼通過phonegap正常工作,但是當作爲Web應用程序發佈時,出現「xmlhttprequest cannont load https://www.facebook.com ...」錯誤。閱讀Facebook的牆壁XML和餵養jQuery的移動網絡應用程序
目前代碼:
<script type="text/javascript">
var cc_news_feed = 'http://www.facebook.com/feeds/page.php?id=47160778899&format=rss20&callback=?';
var cc_news_item = 'item';
var cc_news_title = 'title';
var cc_news_content = 'description';
var cc_news_limit = 10;
$('#news').live('pageshow', function(){
if(newsLoaded != '1'){
cc_news_limit = cc_news_limit +1;
$.mobile.showPageLoadingMsg();
$("#newslist").empty();
$.ajax({
type: "GET",
url: cc_news_feed,
dataType: "xml",
success: parseXml
});
function parseXml(xml10){
var i = 1;
$(xml10).find(cc_news_item).each(function(){
if(i < cc_news_limit){ //Limit results
var pageid = "detailpage" + i;
$("#newslist").append("<li data-theme=\"y\"><a href='javascript:void(0)' onclick=\"javascript: $.mobile.changePage($('"+"#"+pageid+"'), 'slide');\">" + ($(this).find(cc_news_title).text()) + "</a></li>");
$("body").append("<div data-role='page' id='"+pageid+"'><div data-role='header' data-theme='z'><a href='#news' data-direction='reverse'>back</a><h1>News Detail</h1></div><div data-role='content' class='newsdetail'><h1>" + ($(this).find(cc_news_title).text()) + "</h1>" + ($(this).find(cc_news_content).text()) +"</div></div>");
i++;
}
});
$("#newslist").listview('refresh');
$.mobile.hidePageLoadingMsg();
//Mark as loaded
newsLoaded = '1';
}
}
});
</script>
<div data-role="page" id="news" data-theme="z">
<div data-role="header" data-position="fixed" data-theme="z">
<h1>News</h1>
<a href="#home" data-icon="home" class="ui-btn-right" data-iconpos="notext" data-transition="slidedown" data-theme="x">Home</a>
</div>
<div data-role="content">
<ul data-role="listview" data-theme="z" data-inset="true" id="newslist"></ul>
</div>
</div>
我已經讀到了XMLHttpRequest的幾個位,但還是有點迷茫,失去了...