我有兩個div在我的page.the第一個div包含一個導航欄有兩個選項。 我想要做的是當我點擊導航欄中的選項,我想要相應的HTML文件加載在第二個div。 我如何做這個。請幫助。我如何在div中插入外部html文件在jquery移動
這裏是我到目前爲止的代碼..
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test Document</title>
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type = "text/javascript">
function loadSurveyPage()
{
alert("Survey");
$('#myBody').load('survey.html #myQuestions');
}
function howToSurvey()
{
alert("How to Survey");
$('#myBody').load('howToSurvey.html #myQuestions');
}
</script>
</head>
<body id="myBody">
<div data-role="page" id="indexPage">
<div data-role="header" data-position="fixed">
<div data-role="navbar" id="navbar">
<ul>
<li><a href="#" rel="external" onclick="howToSurvey()">How To Take The Survey</a></li>
<li><a href="#" onclick="loadSurveyPage()">Take Survey</a></li>
</ul>
</div>
</div>
<div data-role="content" id="myQuestions"></div>
</div>
</body>
</html>
我得到當我點擊該選項下面的錯誤..
的XMLHttpRequest無法加載文件:/// C:/用戶/ SP05 /Desktop/Self/TMS/testForTab/howToSurvey.html。 Access-Control-Allow-Origin不允許Origin null。