I am developing an application using Symfony2 and jQuery as JavaScript FW. I use Twig for templates. I take the template out of the controller, and after selecting with the cursor in the template, I would like the value of the selected tag to be returned to the controller when sending using the submit button in the specified template.
I am using the following jQuery function:
$("MatchedTag").click(function ()
{
$(this).toggleClass("highlight");
var IdOfTag = this.id;
$.ajax({
url: "{{ path('AcmeAcmeBundle_myaction') }}",
type: "POST",
data: { "tag_id" : idOfTag },
success: function(data) {
}
});
});
I think in the controller in myaction I need to use something like $ _POST ["tag_id"] or getrequest (), bindrequest () to get the value, but I really don't know how to do it. Can anyone give me an example. Thank you
source
share