1

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?

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.