问题描述
我有问题.这不是我第一次使用这种jQuery函数(.load()),但是现在,我真的不明白为什么在这个新网站中它不起作用.在Firebug控制台中,当我单击链接"connexion"时,GET为红色,并且"form.login.php"根本没有加载.为什么?
嗯,顺便说一句,在准备好文档后,正在加载"form.accueil.php".但是没有其他.load调用.这是我的一部分代码.预先感谢.
<!-- 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>';
}
这是'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>
错误在于...缺少#.因此,即使jQuery脚本也无法加载页面.
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>
The error was in the ... it was missing the #. So even the jQuery script was unable to load the page.
这篇关于jQuery函数.load()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!