簡體   English   中英

如何使用 JQuery 加載 HTML 頁面?

[英]How to Load HTML Page Using JQuery?

我正在嘗試使用 JQuery 加載外部 html 文件。 但是,以下代碼不起作用:

<!-- JQuery Code-->
                 <script>
                    $(document).ready(function(){
     
        
        $("#div1").load("header.html");
      
    });
                  </script>
            </head>
         <body>
          
             <div id="div1"></div>
    
          </body>

以下代碼與調試! 看看你有什么問題

$( document ).ready(function() {
    console.log( "ready!" );
    $("#div1").load( "header.html", function( response, status, xhr ) {
  if ( status == "error" ) {
    var msg = "Sorry but there was an error: ";
    $( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
  }
});

});
     

  

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM