Bonsoir,
J'ai suivi le tutoriel sur symfony2 qui est très bon et qui m'a permis de me familiariser avec ce Framework.
J'ai cependant un problème avec le code AJAX.
En effet je ne maitrise pas ce language, et j'ai le plus grand mal à débugger.
Voici le code de ma page html (j'ai adapté le tuto à une problematique immobilière)
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
49
50
51
52 {% extends 'ImmobilierSwitchHomeBundle::layout.html.twig'%} {% block content%} <form id="form_recherche" action = "{{path('immobilier_deal_rechercher')}}" method="post" > <table summary="Recherche rapide"> <caption>Recherche rapide</caption> <tfoot> <tr><th scope="row" colspan =4><input type="submit" value="Rechercher"/></th></tr> </tfoot> <tbody> <tr> <th scope="col" colspan =4>{{form_label(form.motcle)}}</th> <th scope="row" colspan =4> {{form_errors(form.motcle)}} {{form_widget(form.motcle)}} </th> </tr> {{ form_rest(form)}} </tbody> </table> </form> <div class="loading"></div> <div id="resultats_recherche"> {% include 'ImmobilierSwitchHomeBundle:Deal:listDeal.html.twig' with {'deals' : deals} %} </div> <script> $(".loading").hide(); $("#form_recherche").submit(function(){ $(".loading").show(); var motcle = $("#dealrecherche_motcle").val(); var DATA = 'motcle=' + motcle; $.ajax({ type: "POST", url: "{{ path('immobilier_deal_rechercher')}}", data: DATA, cache: false, success: function(data){ alert("success"); $('#resultats_recherche').html(data); $(".loading").hide(); }, error: function(){ alert("error"); } }); return false; }); </script> {% endblock %}
lors de l'execution, j'ai l'alert "error" qui apparaît. J'en déduis qu'il y a une erreur dans l'execution de mon code ajax, mais impossible de savoir où.
Quelqu'un a t il une idée?
Merci,
Partager