Bonjour je tente le tuto du formulaire de rechercher avec ajax.
Mais rien ne se passe quand je tape une recherche

voici mon code
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
//controleur
  public function rechercherContactAction() {
 
        $request = $this->container->get('request');
 
        if ($request->isXmlHttpRequest()) {
 
            $motcle = '';
            $motcle = $request->request->get('motcle');
 
            $em = $this->container->get('doctrine')->getEntityManager();
 
            if ($motcle != '') {
                $qb = $em->createQueryBuilder();
 
                $qb->select('a')
                        ->from('KodAnnuaireBundle:Contact', 'a')
                        ->where("a.email LIKE :motcle")
                        ->orderBy('a.email', 'ASC')
                        ->setParameter('motcle', '%' . $motcle . '%');
 
                $query = $qb->getQuery();
                $contacts = $query->getResult();
 
                } else {
                $contacts = $em->getRepository('KodAnnuaireBundle:Contact')->findAll();
            }
 
            return $this->render(
                    'KodAnnuaire:Repertoire:liste.html.twig', array(
                        'contacts' => $contacts
                    ));
        } else {
            return $this->listerAction();
        }
    }
 
    public function listerAction() {
        $em = $this->container->get('doctrine')->getEntityManager();
        $contacts= $em->getRepository('KodAnnuaireBundle:Contact')->findAll();
 
        $form = $this->container->get('form.factory')->create(new RechercheType());
 
        return $this->render('KodAnnuaireBundle:Repertoire:lister.html.twig', array(
                    'contacts' => $contacts,
                    'form' => $form->createView()
                ));
    }

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
//la vue
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
    <head>
        <title>Hello World avec jQuery</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script> 
    </head>
    <body>
        Dom pas bon
 
        <script type="text/javascript">
           $('body').html('JQuery OK !');
        </script>
 
 
 
            <form id="form_recherche" action="{{ path('rechercher_contact') }}" method="post">
                {{ form_widget(form) }}
                <input type="submit" value="Rechercher" />
            </form>
 
            <div class="loading"></div>
            <div id="resultats_recherche"> 
 
    </body>
</html>
 
   <script>
    $(".loading").hide();
    $("#form_recherche").submit(function(){ 
        $(".loading").show();
        var motcle = $("#recherchecontact_motcle").val();
        var DATA = 'motcle=' + motcle;
        $.ajax({
            type: "POST",
            url: "{{ path('rechercher_contact')}}",
            data: DATA,
            cache: false,
            success: function(data){
               $('#recherchecontact').html(data);
               $(".loading").hide();
            }
        });    
        return false;
    });
   </script>
lorsque je clique sur rechercher sur la console de firebug j'ai une erreur 500

merci d'avance pour la réponse