Rafik Sid
Rafik Sid

Reputation: 1

How to load HTML page into DIV in JSP ( nothing loads )

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>

Upvotes: 0

Views: 1856

Answers (2)

user1930922
user1930922

Reputation:

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");

});

Upvotes: 2

Lance
Lance

Reputation: 3932

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>

Upvotes: 0

Related Questions