0

I am trying to have a little dynamics work in this website http://peps.sqps.nl Everything seems to work well untill I test the website in IE, it just doesnt give any content back.

The js I use is as following:

$(document).ready(function(){
$('li.navItem a').click(function(){
    var url = $(this).attr('href');

    $('article').load(url + ' article', function(){
        $('article').fadeTo(1200, 1);
    });

    return false;
});
});

the html of the dynamic part is as following, where the <article></article> part is supposed to act dynamicly.

<section id="content">
  <div id="article">
    <article>
         content is in here
    </article>
  </div>
</section>

The solution given here on similar problems didnt fix the bug Anyone has any ideas?

Thnx!

James Allardice
  • 164,175
  • 21
  • 332
  • 312
oceanmountain
  • 121
  • 2
  • 9
  • That URL looks a bit weird with the `+ ' article'` – Phil Sep 27 '11 at 09:25
  • 1
    @Phil - That's part of the jQuery `.load` method. It specifies a fragment of the loaded document to use, rather than the whole document. See http://api.jquery.com/load/ – James Allardice Sep 27 '11 at 09:28
  • @JamesAllardice ah yes, now I remember, but shouldn't it be ` #article`? – Phil Sep 27 '11 at 09:29
  • 1
    Problem is that IE won't accept XML "fragments" as valid DOM elements. It probably has sort of "white list" of all valid tags, and you can't treat any other tag as DOM element - jQuery won't help either. Just change the logic and load the contents into ordinary `
    ` instead.
    – Shadow The GPT Wizard Sep 27 '11 at 09:33
  • @ShadowWizard that was indeed the problem :) its fixxed now. Thnx :) – oceanmountain Sep 27 '11 at 09:52

3 Answers3

1

Your URL looks like it would be badly formed.

url = "http://site.com/path/to/page"
load_url = url + ' article'
alert(load_url); // Displays "http://site.com/path/to/page article"

Is this what you really want?

mmcnickle
  • 1,599
  • 10
  • 13
  • I think that probably is what the OP wants. The jQuery `.load` method allows you to specify a selector to load a fragment of a page, rather than the whole document. See http://api.jquery.com/load/ – James Allardice Sep 27 '11 at 09:29
  • As @JamesAlladice mentions above, he could be attempting to load a page fragment but it should be `#article`, not just `article`. – Phil Sep 27 '11 at 09:31
  • The bit after the space can be any jQuery selector, so 'article' is fine actually. But as Shadow Wizard mentions in the comments above, IE might not like treating 'article' as a real DOM element. – mmcnickle Sep 27 '11 at 09:39
  • As @mmcnickle points out correctly. Every version of IE below IE9 doesnt understand article as a DOM, changed it into a div and now it works fine! thnx for the respons :) – oceanmountain Sep 27 '11 at 09:51
0

Add .each(function(){...}); after .load , it should works in IE and Chrome.

        $('#<%=image1.ClientID %>').load(function () {
            //things to do
        }).each(function () {
            if (this.complete) $(this).load();
        });
0

Probably the IE is making cache of your code.

See this post: jQuery's .load() not working in IE - but fine in Firefox, Chrome and Safari

Community
  • 1
  • 1
expertCode
  • 533
  • 4
  • 14