jQuery.charger pour charger un fichier HTML

J'ai jamais utilisé jQuery avant cela, mais je vais vous expliquer ce que je suis en train de faire.

index.html

<!DOCTYPE html>
<html>
    <head>
        <title>My Awesome Website</title>
        <link href="style.css" rel="stylesheet" type="text/css"/>
        <link rel="shortcut icon" href="/favicon.ico" />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    </head>
    <body>

<!--    <iframe width="100%" height="175" frameborder="0" scrolling="no" src="navbar.html"></iframe> I used to use this - but i cant have dropdown menus. -->
            <!-- This is my problem -->
        <script>
                $('#navbar').load('./navbar.html');
        </script>
        <noscript>
            <h1>Please enable Javascript!</h1>
        </noscript>

        <div id="container">
                <!-- Content Here -->
        </div>

    </body>
</html>

navbar.html

<div id="navbar">
        <li><object width="64" height="64" data="favicon.svg" type="image/svg+xml"></object></li>
        <li><object width="64" height="64" data="icons/tech.svg" type="image/svg+xml"></object></li>
        <li><object width="64" height="64" data="icons/games.svg" type="image/svg+xml"></object></li>
        <li><object width="64" height="64" data="icons/contact.svg" type="image/svg+xml"></object></li>
</div>

Donc ce que j'essaie de faire ici, c'est avoir beaucoup de pages HTML qui tous lien à une barre de navigation de la page html, donc quand j'ai changer la navbar.html, je n'ai pas changer à chaque page.

J'ai déjà une autre question ici. Davor Milnaric suggéré "si vous utilisez jquery, vous pouvez essayer avec '.load () de la fonction. api.jquery.com/load" mais je ne peux pas le faire fonctionner. Ce que je fais mal? Comment puis-je résoudre ce problème? Toute aide serait grandement appréciée.

InformationsquelleAutor Yharooer | 2013-05-26