jquery - URL argument passing from ajax to symfony2 controller via rounting.yml -


I'm trying to pass the argument URL to symfony2 controller jquery, but not in the path routing.yml File found .. Please help me with that

  // $ jQuery code $ every. (SearchResult, function (key, value) {$ ("# course_list") enclosed ('& lt; h4 & gt; & lt; a href = "{{path (" FrontEndBundle_course ", {" id ": '+ value.id +'})}}" & 'gt;' + value.name + & lt; / a & gt; & Lt; / h4 & gt; & lt; p & gt; '+ Value.description +' & lt; / p & gt; ')});  

routing.yml

  Course: Pattern / courses defaults: {_controller: FrontEndBundle: Course: Index} requirements: _method: get  

Controller

  Public Function Index Action ($ ID) {Return $ this- & gt; Reader ('Frontend Bundle: Course: course.html.twig', array ("id" => ID $)); }  

Try changing JS:

  // jQuery code $ .Each (SearchResult, function (key, value) {$ ( "# course_list") attached (. '& lt; h4 & gt; & lt; a href = "{{path (" of course " {"Id": '+ value.id +'})}} "> '+ value.name +' & lt; / a & gt; & lt; / h4 & gt; & lt; p & gt; '+ Value.description +' & lt; / p & gt; ')});  

You can id in routing.yml

  course: pattern: / course / {forget Default ID: {_controller: FrontEndBundle: Course: Index} Requirements: _method: GET  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -