1

I have a simple HTML page with these jQuery statements:

$(document).ready(function() {
    $('#myDiv').load('mypage.html');
});   

For some reason this doesn't load any HTML to the div. I used this method to make sure the source file exists - everything checks out fine. I tried using the error callback on .load() and the status is "error", but the response is empty. Looking at the console I see the following GET request:

[12:18:20.770] GET http://localhost/ [HTTP/1.1 200 OK 0ms]

Finally, when I do a simple $('#myDiv').html('test'); it loads fine, so I know the div is set up properly.

Can anyone think of what's going wrong here? I'm running WAMP on Windows, if that's any help.

Cœur
  • 37,241
  • 25
  • 195
  • 267
serverpunk
  • 10,665
  • 15
  • 61
  • 95

1 Answers1

1

try

$('#myDiv').load('/root/folder/mypage.html');

also try.

$('#myDiv').html('Did i disappear?');
$('#myDiv').load('/root/folder/mypage.html');
///// Is myDiv empty when the page loads?
Brutnus
  • 163
  • 2
  • 9
  • The .html() before the .load() made it work! I'm curious though... why do I need that? – serverpunk Oct 08 '12 at 19:51
  • `$('button').click(function(){ $('#content').load('hi.html'); });` – Brutnus Oct 08 '12 at 20:07
  • Thats really odd. Can you try creating a new div and try .load into that div as well. So we want to try and do .load into 2 seperate divs. – Brutnus Oct 08 '12 at 20:56
  • I made a new div and tried a simple .html() on it. The content will change for as long as my browser status is "waiting for localhost" and then reverts back to the original text. Looks just like a refresh, but I'm not doing anything like that in the script. – serverpunk Oct 08 '12 at 21:44
  • Well sorry we couldn't find the exact answer. – Brutnus Oct 10 '12 at 20:38