views:

523

answers:

3

I am having troubles with jQuery's load function and am hoping for some help. I just started testing a site I built in IE to debug/hack/etc to make sure it works. Firefox/safari/etc all work great. .load won't work for me though. It just seems to hang. Would love some help.

Here is a simplified version of the problem:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  <script>
      $(document).ready(function(){
     $("#links").load("newfull.asp #Body");
      });
  </script>
</head>
<body>
    <div id="links">
     test area
    </div>
</body>
</html>

Page can be viewed at http://www.stephenkiers.com/2010/delete.html

A: 

$("#links").load("newfull.asp #Body");

try it without the space

$("#links").load("newfull.asp#Body");

Funky Dude
I tried this, and it still didn't work.
Stefan Kendall
IE8 developer tools rock, by the way.
Stefan Kendall
did you actually try it or just try it with developer tools?cause if you type newfull.asp #Body directly into ie nav bar, you get a 404 page
Funky Dude
the space is what jQuery uses to determine what part of the page is returned. So this request will ONLY return the #Body div from the requested page.
S.Kiers
+2  A: 

From your question it's not exactly clear if you're only having a problem in IE, but when I hit the supplied page in FF, Chrome and Opera it loads as expected. When I browse to it in IE, I get a blank page as described. Thus, I'm assuming you experience the same thing and IE fails to render like the others.

Tracing the IE request in Fiddler I see the content page (newfull.asp) is requested and delivered, which suggests the problem lies in the jQuery selectors that are passed to the load call. Since it works in the other browser it seems like a quirk the IE DOM related to the specific page (or just a general bug with jQuery and IE). Usually when I hit such problems I check to see how well formed the markup is, and in this case there's a few validation errors. It might be worthwhile to resolve the validation errors and see if it has an impact on IE's behavior.

John
I am fixing these errors now... will let you know.
S.Kiers
It is now error free. Good catch. I didn't think of that. To bad it doesn't affect it at all.
S.Kiers
+3  A: 

Have you tried specifying the path as an absolute URL instead of relative to the current document?

$("#links").load("/path/to/newfull.asp #Body");

A quick look at the jQuery page shows that relative URLs should be acceptable, but its worth a shot I suppose.

EDIT: Are you intending to use #Body to select the the body element or an element with the ID of Body?

Lachlan McDonald
I will change the name from Body. That could be messing it up. I should know better than to use HTML elements as ID names... tsk tsk
S.Kiers
It was that simple. #Body was throwing an error. Thanks!
S.Kiers