2013-05-06 2 views
0

HTML 페이지에서 다른 페이지의 div로 ul을로드하는 스크립트가 있습니다. 내 탐색 메뉴를위한 것이지만로드되지 않습니다. ul은 ID 이름을 가지고 있으며 ID를 사용하여 ul을로드하고 ul이있는 전체 HTML 페이지를로드하지 않습니다.왜이 코드에서 AJAX load()가 작동하지 않습니까?

//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>  
+2

귀하의'로드() '함수는 ... 내부''태그로 표시되지 않습니다 당신은 그들 내부에 그것을 넣어 봤어? 콘솔에 오류가 있습니까? – lifetimes

+0

이 기능은 자체 .js 페이지에 있습니다. – Spilot

답변

1

수정이,이 주소의 형식이 잘못된 것 같다 : $('#nav').load("http://myDomain.com/menu.html #navig");

#navig 그냥 해시하고 client-side이다 애플리케이션을 위해, SERVER-SIDE에서 작동하지.

행운

관련 문제