jQuery function .load() doesn't work

2019-09-08 11:25发布

问题:

i have a problem. It's not the first time i use this jQuery function ( .load() ) that way, but now, i really can't understand why in this new web site, it's not working. In the Firebug Console, when i click on the link "connexion" the GET is in red and the 'form.login.php' is not loaded at all. Why?

ah by the way, on document ready, the loading of 'form.accueil.php' is working. But not the other .load call.

Here is a piece of my code. Thanks in advance.

<!-- SCRIPT -->
<script type="text/javascript" src="js/jquery-1.8.2.js" ></script>
<script type="text/javascript">

    function menuClick(tab)
    {

        switch (tab)
        {
            case -1: // accueil
                // alert(tab+':accueil');
                // $('#main_center').empty();
                $('#main_center').load('form.accueil.php');
                break;

            case 0: // connexion
                // alert(tab+':connexion');
                // $('#main_center').empty();
                $('#main_center').load('form.login.php');
                break;
        }   
    }

    $(document).ready(function() 
    {
        $('#main_center').load('form.accueil.php');
    });

</script>

</head>
<body>

<div id="wrap">
    <!-- HEADER -->
    <div id="header">
        <div id="menu">
            <ul class="menu">
                <?php
                    // Affichage du menu
                    echo '<li onClick="menuClick(-1);"><a class="" id="tab1" href="">Accueil</a></li>';

                    if (!$oLogin->get_connected())
                    {
                        // si pas connecté on affiche le module de connexion
                        echo '<li onClick="menuClick(0);"><a class="" id="tab2" href="">Connexion</a></li>';
                        // echo '<li onClick="menuClick(0);"><a class="" id="tab2" href="">Connexion</a></li>';
                        echo '<li onClick="menuClick(666);"><a class="" id="tab2" href="">Test</a></li>';
                    }

And here is 'form.login.php'

<form name="Identification" method="post" action="index.php">
    <table class="side-menu">
        <tr>
            <th colspan="2" id="th_conn">CONNEXION</th>
        </tr>
        <tr>
            <td></td>
        </tr>
        <tr>
            <td align="left">Nom d'utilisateur</td>
            <td><center><input class="text" type="text" name="usager"></center></td>
        </tr>
        <tr>
            <td align="left">Mot de passe</td>
            <td><center><input class="text" type="password" name="passwd"></center></td>
        </tr>
        <tr id="submit" valign="top">
            <td></td>
            <td><center><input class="submit" type="submit" value="Soumettre"></center></td>
        </tr>
    </table>
</form>

回答1:

The error was in the ... it was missing the #. So even the jQuery script was unable to load the page.