我有一个脚本,可以将 ul 从 html 页面加载到另一个页面上的 div 中。它应该是我的导航菜单,但它不会加载。ul 有一个 id 名称,我使用 id 来加载 ul,而不是加载 ul 所在的整个 html 页面。
//This is the page I want the ul to load to.
<body>
<div id="fb-root"></div>
<script>
//facebook registration init code omitted
</script>
//this is the div where I want the ul to load
<div id="nav">
</div>
// in this div is the facebook registration plug in iframe that shows after the fbinit code runs.
<div>
<iframe src="https://www.facebook.com/plugins/registration?
client_id=3967*****188&&
redirect_uri=http://myDomain.com/signedRequest.php&
fields=name,password"
scrolling="auto"
frameborder="no"
style="border:none"
allowTransparency="true"
width="100%"
height="330">
</iframe>
</div>
<button>Button label</button>
// jqueru UI method
<script>
$(function(){
$( "button" ).button();
});
</script>
//The rest of the page markup omitted
</body>
</html>
//this is the script where I call the load()
//The load to #mainDiv is for use on another page
//note that I'm only trying to load the ul with id navig, and not the whole html page.
$(function(){
$("#mainDiv").load("http://myDomain.com/find2.html");
$('#nav').load("http://myDomain.com/menu.html #navig");
});
//this is the menu.html page with the ul.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<ul id="navig">
<li><a href="#"> gatherings I'm hosting</a></li>
<li><a href="#"> gatherings I'm invited to</a></li>
</ul>
</body>
</html>