Bonjour,

Je suis en train de réaliser une application qui nécessite un peu d'Ajax. Je m'aide de ce tutoriel.

Ma fonction ajax ne fonctionne pas, et j'ai pu, à l'aide de Firebug, observer l'erreur suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
...
x-wf-1-1-1-1	306|[{"Type":"ERROR","File":"","Line":"","Label":"request"},"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException: No route found for \"POST \/card\/%7B%7B%20path(%27CaCardBundleGetAddress%27)%20%7D%7D\" (uncaught exception) at C:\\wamp\\www\\sf2card\\app\\cache\\dev\\classes.php line 4533 [] []"]|
...
Voici ma fonction :

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
 
...
$("#ca_cardbundle_cardtype_city").change(function() {
  //GET
  var param = $('#ca_cardbundle_cardtype_city option:selected').text();
 
  param = 'city=' + param;
  //REQUEST
  $.ajax({
    type: "POST",
    url: "{{ path('CaCardBundleGetAddress') }}",
    data: param,
    cache: false,
    statusCode: {
      404: function() {
        alert('page not found');
      }
    },
    success: function(param){
      $('#destination').html('hello' + param);
    //$("#ca_cardbundle_cardtype_address").append($("<option></option>").
    //  attr("value",1).
    //  text(param));
    }    
  });  
});
...
J'ai bien rajouté la route :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
CaCardBundleGetAddress:
    pattern: /addresses
    defaults: {_controller: CaCardBundle:Address:addresses }
    requirements:
        _method: POST
D'avance, merci de votre aide

Bonne fin de journée