使用symfony 1.4的ajax存在问题

使用symfony 1.4的ajax存在问题,ajax,symfony-1.4,jobeet,Ajax,Symfony 1.4,Jobeet,在symfony1.4中使用ajax时,我遇到了一个非常奇怪的问题。我使用了jobeet示例(第18天),但它不起作用 这是我的indexSuccess.php <script type="text/javascript" > $(document).ready(function(){ $('#buscador').keyup(function(key) { if (this.value.length >= 3 || this.value == '')

在symfony1.4中使用ajax时,我遇到了一个非常奇怪的问题。我使用了jobeet示例(第18天),但它不起作用

这是我的indexSuccess.php

<script type="text/javascript" >

$(document).ready(function(){

$('#buscador').keyup(function(key)
{
       if (this.value.length >= 3 || this.value == '')
       {
           $('#per').load( $(this).parents('form').attr('action'),
                        { query: this.value + '*' });
       }
   });
});
</script>

<h1>Lista de personas</h1>

 <p>Busque o cree registros de personas en el sistema (Estudiantes, funcionarios,  docentes).</p>

<form action="<?php echo url_for('personas/index')?>">
<table>
    <tr>
        <td><input type="text" name="buscar" id="buscador"/></td>
        <td><a href="<?php echo url_for('personas/index')?>"><img src="/images/iconos/Search.png"/></a></td>
    </tr>
</table>
</form>
<p style="font-size: 11px;color: gray;">Digite un nombre, apellido o número de identificación para buscar</p>

<div class="per" id="per">
<?php echo include_partial('personas/buscaPersonas',array('personass'=>$personass)); ?>
</div>
当我加载页面时,我不想看到任何结果。因此,当我进行ajax调用时,我应该重新加载包含所有结果的部分“_buscaPersonas.php”(仅供尝试),但我会加载_form.php部分

这是我的一部分:

 <table>
 <?php foreach($personass as $personas): ?>
 <tr>
 <td colspan="5" class="tituloTD"><?php echo $personas->getNombre(); ?></td>
 </tr>
 <tr>
 <th>Numero identificación: </th><td><?php echo $personas->getNumeroid() ?></td>
 <th>Email: </th><td><?php echo $personas->getEmail(); ?></td>
 <td><a href="<?php echo url_for('personas/edit?id='.$personas->getId()) ?>"> <img src="/images/iconos/editar.png"/></a></td>
    </tr>
        <?php endforeach; ?>
   </table>

识别数字:
电邮:
我一直想找出问题出在哪里,但我不明白。当我使用按钮进行正常搜索时,它会工作,加载正确的部分,但使用ajax加载其他部分

请有人知道我的错误是什么


谢谢

我认为这是由于加载ajax函数的路径:

       $('#per').load( $(this).parents('form').attr('action'),
                    { query: this.value + '*' });
$(this).parents('form').attr('action')肯定是一个错误的值。 试试这个:

('personas/index')的url\u

最后我找到了错误。我不知道会发生什么,但如果我用加载函数发送数据,我会出错。因此,我必须使用url发送数据,并且是有效的:)

if(this.value.length>=3 | | this.value=='')
{ 
$('#per').load(“+”?query=“+this.value”);
}

我试图改变这一点,但不起作用。在加载ajax时,我一直尝试使用相同的结果渲染其他部分。
       $('#per').load( $(this).parents('form').attr('action'),
                    { query: this.value + '*' });
 if (this.value.length >= 3 || this.value == '')
 { 
   $('#per').load( "<?php echo   url_for('personas/index')?>"+"?query="+this.value);
 }