Html 为什么不是';我的AJAX load()在这段代码中工作吗?
我有一个脚本,它将一个ul从一个html页面加载到另一个页面上的div。它本来是我的导航菜单,但不会加载。ul有一个id名称,我使用该id加载ul,而不是加载ul所在的整个html页面Html 为什么不是';我的AJAX load()在这段代码中工作吗?,html,ajax,dom,Html,Ajax,Dom,我有一个脚本,它将一个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
//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>
//这是我希望ul加载到的页面。
//facebook注册初始化代码省略
//这是我想要ul加载的div
//在这个div中是在fbinit代码运行之后显示的facebook注册插件iframe。
按钮标签
//jqueryui方法
$(函数(){
$(“按钮”).button();
});
//页面标记的其余部分被省略
//这是我调用load()的脚本
//加载到#mainDiv用于另一个页面
//请注意,我只是尝试用id navig加载ul,而不是加载整个html页面。
$(函数(){
$(“#mainDiv”).load(“http://myDomain.com/find2.html");
$('#nav')。加载(“http://myDomain.com/menu.html #导航);
});
//这是带有ul的menu.html页面。
修复此问题,地址的格式似乎有误:
$('#nav')。加载(“http://myDomain.com/menu.html #导航)代码>
#navig
只是一个散列,在服务器端
中不起作用,对于应用程序来说,它是客户端
祝您好运您的load()
函数似乎不在
标记内。。你试过把它放进去吗?您的控制台中是否收到任何错误?该函数位于其自己的.js页面上。