How come the content form the “body.html” file isn’t loaded into the “section2”-div?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<script src="jquery-1.6.2.min.js"></script>
<script language='javascript' type='text/javascript'>
$(document).ready(function(){
alert("Document ready");
$.get("body.html", function(data){
alert("Data Loaded: ");
$("#section2").html(data);
});
});
</script>
</head>
<body>
<div id="section2">
</div>
</body>
</html>
body.html:
Content for all!
Both alerts are triggered.
Thank you in advance!
The problem is that the response headers content type has to be “text/html” when calling body.html.
To avoid errors, use :
or
or