ajax - AngularsJS POST JSON data to Symfony2 -


i know why not working , have angularjs app witch sends trough ajax data symfony2 application. can see, data sent in network console

<?php  namespace supbox\cloudbundle\controller;  use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\jsonresponse; class foldercontroller extends controller {     public function createaction(){         $post = $this->getrequest()->request;         $name = $post->get("name");         $folder = $post->get("folder");         var_dump($post);         die;      } } 

angularjs code

    $http({             method: 'post',              url: route.folder.create,              data: {                 folder: $scope.id,                 name: name             }         }) 

opera network console output

request url:http://localhost/supbox/web/box/folder/create request method:post status code:200 ok request headersview source accept-encoding:gzip,deflate,lzma,sdch accept-language:fr-fr,fr;q=0.8,en-us;q=0.6,en;q=0.4 connection:keep-alive content-length:25 content-type:application/json;charset=utf-8 host:localhost origin:http://localhost referer:http://localhost/supbox/web/box/ user-agent:mozilla/5.0 (windows nt 6.3; wow64) applewebkit/537.36 (khtml, gecko) chrome/33.0.1750.154 safari/537.36 opr/20.0.1387.82 request payloadview source {folder:1, name:ang} response headersview source connection:keep-alive content-length:431 content-type:text/html date:mon, 24 mar 2014 13:25:53 gmt keep-alive:timeout=5, max=100 server:apache/2.4.4 (win64) openssl/1.0.1d php/5.4.12 x-powered-by:php/5.4.12 

if (angular js) post data through header json need change code this:

public function createaction(){     $post = $this->getrequest()->getcontent();     $post = json_decode($post);     $name = $post->name;     $folder = $post->folder;     var_dump($post);     var_dump($name); // null     var_dump($folder); // null     die;  } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -