Francesco Arreghini
Francesco Arreghini

Reputation: 99

symfony FOSJsRoutingBundle generate url

Can someone help me understand how to generate url with FOSJsRoutingBundle?

I have a route :

            /**
 * @Route("/ajax/send/mail/assistance/{center}/{ind_stu}",
 *     defaults = { "center" = 1 ,"ind_stu"=1},
 *     options = { "expose" = true },
 *     name = "ajax_stu_sendmail_assistance",
 * )
 */
    public function sendmailassistanceStuAction(Request $request,$center,$ind_stu,\Swift_Mailer $mailer)
    {

in my jquery file i write

var path =Routing.generate('ajax_stu_sendmail_assistance',{ $center:center,$ind_stu:ind_stu});

i want that the url to call :

/ajax/send/mail/assistance/nr_center/nr_ind_stuf

but i don't know why it calls :

/ajax/send/mail/assistance?%24center=nr_center&%24ind_stuf=nr_ind_stuf

It works for another example when i use only 1 variable, can somone help?

Upvotes: 1

Views: 116

Answers (2)

Matteo
Matteo

Reputation: 39390

Try flipping the arguments (the first is the key) as follow:

var path =Routing.generate('ajax_stu_sendmail_assistance',{ center:$center,ind_stu:$ind_stu});

Hope this help

Upvotes: 1

Yashvantsinh Zala
Yashvantsinh Zala

Reputation: 531

I think you mistake in generate route syntax. Please remove $

var path =Routing.generate('ajax_stu_sendmail_assistance',{ center:center,ind_stu:ind_stu});

Please check this https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/usage.html

Upvotes: 2

Related Questions