我试图从 Facebook 读取基本的墙信息,并显示在查询移动列表中。该代码通过 phonegap 工作正常,但是当作为 Web 应用程序发布时,出现“xmlhttprequest cannont load https://www.facebook.com ...”错误。
当前代码:
<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 的内容,但仍然有点困惑和迷失......