Question

Hi this code does not run under ie7/ie8 for some reason.

$('#cnt').load('./tiles/pages/'+ $name +'.php #'+$lang, showNewContent());

It seems to have problems to retrieve the section in the php file with the id $lang. The code works in all other browsers, and it works in ie7/ie8 if I call it like that:

$('#cnt').load('./tiles/pages/'+ $name +'.php', showNewContent());

and I don't like that.

Any idea why ie7/ie8 behave this way? ok ie7 I know => it is crap :-)

For now the php file just contains plain html5 which looks like that:

<article id="de">
        <header>
            <h2>Your article heading</h2>
        <p>Lorem ipsum dolor sit amet.</p>
        </header>
        <h3>A smaller heading</h3>
            <p>Lorem ipsum dolor sit amet</p>   
        <h3>A smaller heading</h3>
            <p>Lorem ipsum dolor sit amet</p>
        <footer>
        <h3>About the author</h3>
            <p>Lorem ipsum dolor sit amet</p>
        </footer>
</article>
<article id="en">
        <header>
            <h2>Your article heading</h2>
        <p>Lorem ipsum dolor sit amet.</p>
        </header>
        <h3>A smaller heading</h3>
            <p>Lorem ipsum dolor sit amet</p>   
        <h3>A smaller heading</h3>
            <p>Lorem ipsum dolor sit amet</p>
        <footer>
        <h3>About the author</h3>
            <p>Lorem ipsum dolor sit amet</p>
        </footer>
</article>

UPDATE:

As it looks like, it is the HTML5 tags that throw it off??? I am using modernizr, anyone want to take a hit on that? In the dom only <article id="de" /> is loaded the rest is neglected.

Was it helpful?

Solution

Update 1

You said that calling the code without # works ok, so since with the load method and ID selector you are actually fetching all the document, but jQuery will only keep the code within the specified element ID, you could simply call the load method without an ID selector, then keep only the element you need and remove the rest yourself.


Maybe the space in the URL is the problem, could you try to escape it somewhat?

Like

$('#cnt').load('./tiles/pages/'+ $name +'.php%20#'+$lang, showNewContent());

or

$('#cnt').load('./tiles/pages/'+ $name +'.php%2520#'+$lang, showNewContent());

OTHER TIPS

Probably too late, but did you try re-applying modernizr on your newly loaded html?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top