2017-10-03 2 views
1

학교용 html 페이지가 있으며 메뉴 막대를 만들어야합니다. 나는 지방 그래서 난 내 페이지 습관이 파일을로드jQuery 아약스로드 코드

menu.html

<html> 
<body> 
    <nav class="navbar navbar-inverse" 
     <div class="container-fluid"> 
      <div class="navbar-header"> 
       <a class="navbar-brand">Practice</a> 
      </div> 
      <ul class="nav navbar-nav"> 
       <li class="active"></li> 
     </div> 
    </nav> 
</body> 

미디어 화재 menu.html을 업로드하기로 결정을 만들고 싶어, 아무것도 없다 출력에.

practiceblank.html

<html> 
<head> 
    <title>Testing Webpage</title> 
    <link rel="stylesheet" href="bootstrap.min.css"> 
    <link rel = "stylesheet" type = "text/css" href = "main.css"/> 
    <link rel='icon' href='favicon.ico' type='image/x-icon'/> 
    <script> 
     var clicks = 0; 
     cps = 1; 
     function countClicks() { 
      clicks += 1; 
      document.getElementById("clicks").innerHTML = clicks; 
     } 
    </script> 
</head> 
<body class="an1"> 
    <div id="div1"><h2>Let jQuery AJAX Change This Text</h2></div> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> 
     jQuery("#div1").load("http://download1473.mediafireuserdownload.com/feen32om7deg/ebw8k296r8caucm/menu.html"); 
    </script> 
<!--The rest is personal--> 
+0

나는 이것이 막연하다는 것을 깨달았습니다. 기본적으로 jQuery ("# div1") .load ("http://download1473.mediafireuserdownload.com/feen32om7deg/ebw8k296r8caucm/menu.html"); 은 문제가 아니며 단지 나타나지 않습니다. 수동으로 콘솔에서 실행하면 – SeaGemGames

+0

예, 코딩하는 동안 로컬로 파일을 사용하는 것이 좋습니다! –

답변

1

당신은이 스크립트 라이브러리의 포함 분리해야이 도움이

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 

<script>  
    $(function(){   
     jQuery("#div1").load("http://download1473.mediafireuserdownload.com/feen32om7deg/ebw8k296r8caucm/menu.html"); 
    }); 
</script> 

희망을.

+0

감사! 나는 그것을 사전에 시도했지만, 나는 단지 내 코드가 원래 잘못되었다는 것을 깨닫지 못했을 것이라고 생각한다. – SeaGemGames

관련 문제