2017-08-09 81 views
1

有人可以幫我理解如何使用FOSJsRoutingBundle生成url嗎?symfony FOSJsRoutingBundle生成url

我有一個路線:

  /** 
* @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) 
    { 

在我的jQuery的文件我寫

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

我想,網址撥打:

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

但我不」不知道爲什麼會這麼叫:

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

它適用於另一個例子,當我只使用1個變量,可以somone幫助嗎?

回答

1

嘗試翻轉參數(一個是關鍵)如下:

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

希望這有助於