I wanted to get views from the symfony community about how one would achieve using backbone.js
to create a one paged application.
Is it even possible to call the functions in symfony (e.g public function executeCreate()) through backbone.js) has anyone done it?
Can you give me some resources? thanks in advance.
在Backbone.js中使用Symfony
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- douyue1926 2012-04-27 16:27关注
Why not? Symfony easily can return JSON data on request by backbone clientside app. For Symfony2 it can be like this:
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class MyController extends Controller { public function createAction($requestParam1, $requestParam2) $response = new Response(json_encode(array( 'requestParam1' => $requestParam1, 'requestParam2' => $requestParam2 ))); $response->headers->set('Content-Type', 'application/json'); return $response; } }
解决 无用评论 打赏 举报