Via jquery, I ajax / POST this json
{"indices":[1,2,6]}:
for symfony2 action. Right now, I only really care about the array, so if that makes it much easier, I could just post [1,2,6].
How can I convert this to a php object?
Somehow this does not work:
public function applySortIndexAction() { $request = $this->getRequest(); $j = json_decode($request->request->get('json')); $indices = $j->indices; return array('data'=> $indices); }
gives
Note: attempt to get non-object property in ... /PageController.php line 64 (500 Internal Server Error)
where I will access the indices $ j->, where $ j seems to be zero
Poster:
$.ajax({ type: 'POST', url: "{{ path('page_applysortindex')}}", data: $.toJSON({indices: newOrder}), success: ...
source share