I send text message like this
html markup
<textarea id="request" cols="20" rows="4"></textarea>
javascript code
var data = {request : $('#request').val()};
$.ajax({
type: "POST",
url: "{{ path('acme_member_msgPost') }}",
data: data,
success: function (data, dataType) {
alert(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('Error : ' + errorThrown);
}
});
symfony2 controller code
$request = $this->container->get('request');
$text = $request->request->get('data');
but $text is null ...
I have tried normal post request (not Ajax) by firefox http request tester.
/app_dev.php/member/msgPost
Controller works and $text has a value.
So I think the php code is OK, there is the problem on Ajax side, however
'success:function' is called as if succeeded.
How can you get the contents of javascript data structure?
$text = $this->getRequest()->get('request');