我有以下使用 PhoneGap 和 JQuery Mobile 的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=320; user-scalable=no" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Test RSS</title>
<script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery-1.7.2.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery.mobile-1.1.1.js"></script>
<link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.1.css" />
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script type="text/javascript" charset="utf-8">
var onDeviceReady = function() {
... //some code
$("#homePage").live("pageinit", function() {
... //some more code
});
};
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
</script>
</head>
<body onload="init();" id="stage" class="theme">
<div data-role="page" id="homePage">
<div data-role="header">
<h1></h1>
</div>
<div data-role="content">
<ul id="linkList" data-role="listview" data-inset="true"></ul>
</div>
<div data-role="footer">
<h6>Market Bytes by @toddysm</h6>
</div>
</div>
<div data-role="page" id="contentPage">
<div data-role="header">
<a href="#homePage" data-rel="back">Home</a>
<h1></h1>
</div>
<div data-role="content" id="entryText"></div>
</div>
</body>
</html>
出于某种原因,虽然我在执行 $("#homePage").live("pageinit", function() 时看到以下错误: XMLHttpRequest cannot load http://127.0.0.1:44104/[some-GUID]. Origin Access-Control-Allow-Origin 不允许 null 问题是我没有尝试加载单独的页面,并且到目前为止我发现的建议不起作用。
任何想法解决方案是什么?