jQuery function .load() doesn't work

半世苍凉 提交于 2019-12-13 06:06:52

问题


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.



来源:https://stackoverflow.com/questions/12773255/jquery-function-load-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!