0

Can anybody give me advice on how to make it work?

<html>
<head>
    <script src="../js/jquery-1.9.1.js"></script>
</head>
<body>
    <div id="divpage"></div>
    <script>
      $("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");
      alert( "Load was performed." );
    </script>
</body>
</html>
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Rafik Sid
  • 1
  • 3
  • Possible duplicate http://stackoverflow.com/questions/17636528/how-do-i-load-an-html-page-in-a-div-using-javascript – mwilson May 06 '15 at 23:32

2 Answers2

2

The browser has to load the full DOM, before you can manipulate it with javascript, In Jquery use .ready()

$(document).ready(function()
{
    $("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");

});
0

Move your script block out of the body and up in the head section. Then, wrap your JQuery like this:

<script>
$(document).ready(function()
{
    $("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");
    alert( "Load was performed." );
});
</script>
Lance
  • 3,824
  • 4
  • 21
  • 29