I am trying to load an external html file using JQuery. But, the following code does not work:
<!-- JQuery Code-->
<script>
$(document).ready(function(){
$("#div1").load("header.html");
});
</script>
</head>
<body>
<div id="div1"></div>
</body>
CodePudding user response:
the following code with debug !! to see what is your problem
$( 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 );
}
});
});