2014-08-27 5 views
0

다음은 내 사이트의 일부이며, 내가 아는 일부 코드가 삭제 된 것입니다.load() 함수에 문제가있는 경우

<div id="Container"> 
<div id="Header"></div> 
<div id='TopNav'> 
<ul> 
    <li> <a href=''>Home</a></li> 
    <li><a href ='' id='bt1'>Contact EHC</a></li> 
    <li><a href=''>Student Portal</a></li> 
    <li><a href=''>Lecturer Portal</a></li> 
    <li><a href=''>How To Apply</a></li> 
    <li><a href=''>Student Union</a></li> 
    <li><a href=''>News</a></li> 
    <li><a href=''>Tutorials</a></li> 
    <li><a href=''>Log In</a></li> 
    <li class='last'><a href=''>Graduation</a></li> 
</ul> 
</div> 
<!-- topNav closes here --> 

<div id="Content"></div> 
<!-- Content div ends here --> 

<div id="Footer"></div> 
</div> <!-- conatiner closes here--> 

#content의 CSS는 않습니다 : 내가 jQuery를 기능을 사용하려고하면

$(document).ready(function(){ 

    $('#bt1').click(function() { 
     $('#content').load('other.html'); 
    }); 

}); 

것은 작동하지 않습니다 위 :

#Content { 
float: left; 
height: auto; 
width: 800px; 
border-style: solid; 
border-width: thin; 
background-color: #F5FDFE; 
text-indent: 0px; 
text-align: justify; 
padding-top: 0px; 
padding-right: 5px; 
padding-bottom: 3px; 
padding-left: 5px; 
} 

내 jQuery를 기능은 다음과 같습니다 , "Contact EHC"를 클릭하면 #content div는 그냥 공백으로 남습니다. 콘솔에 오류가 표시되지 않습니다. WAMP를 테스트 서버로 사용하고 있습니다. jQuery 함수가 작동하지 못하게하는 코드에 문제가 있습니까? 경고 ('Hello')와 같은 간단한 코드; 내가 거기에 포함하면 잘 작동합니다. 문제가 분명하다면 사과 드리며 웹 개발을 가르치고 있습니다. 대학에서의 마지막 학년 프로젝트입니다.

+0

AJAX 호출이 제대로 작동하는지 콘솔에서 확인할 수 있습니까? 우리는 당신의 localhost 환경에 대한 세부 사항을 모르기 때문에 '/other.html'에서 오는 데이터가 없을 수도 있습니다. ?? – shershen

+0

더 이상 사용되지 않는 .load 사용을 피하십시오. http://api.jquery.com/load-event/ – Frisbetarian

+1

@Frisbetarian, OP는 http://api.jquery.com/load/를 사용하고 있습니다. – Satpal

답변

2

을 내가 다음되는 링크를 방지 할 몇 가지 코드를 포함 잊고 것을 발견 몇 가지 조사 후. 다음 코드는 나에게 잘 돌아갔다. 고맙습니다.

$('#bt1').click(function() { 
$('#content').load('other.html'); 
return false; <----------- This is the code i was missing out 
}); 
0

사용이

$("#content").html('<object data="http://other.html/">'); 
0

이 시도 :

<script type="text/javascript"> 
     $(document).ready(function() { 
      $('#bt1').click(function() { 
       $("#content").load('/jquery/result.html'); 
      }); 
     }); 
    </script>