2012-09-11 5 views
0

내가 다시로드 페이지없이 사업부에서 링크를 표시하는 JQuery와 있습니다 jQuery를 코드 :jQuery 코드에서 스피너 이미지를 추가

<script type="text/javascript"> 
$(document).ready(function() { 
    $("a").click(function(event) { 
     // Prevent default click action if javascript is enabled 
     event.preventDefault(); 
    //load the content of the new page into the content of the current page 
    $("#content").load($(this).attr("href") + " #content"); 
    }) 
}); 
</script> 

모든 벌금과 작업입니다, 그러나 이것은 너무 간단하다! 이 코드에서 내용을로드하기 전에로드하는 이미지를 어떻게 추가 할 수 있습니까?

두 번째 질문은로드 한 후 주소 표시 줄에 새 페이지 링크를 표시 할 수있는 방법이 있습니까?

답변

4

콜백 함수를 사용하여 로더를 제거 할 수 있습니다.

<script type="text/javascript"> 
$(document).ready(function() { 
    $("a").click(function(event) { 
     // Prevent default click action if javascript is enabled 
     event.preventDefault(); 
     //load the content of the new page into the content of the current page 
     $('#loader').show(); // Show some hidden loader on the page 
     $("#content").load($(this).attr("href") + " #content", function() { 
      $('#loader').hide(); // Hide the loader when it completely loads the given URL. 
     }); 
    }) 
}); 
</script> 

두 번째 질문은 대답입니다. Change the URL in the browser without loading the new page using JavaScript

관련 문제