{"action":"closed","issue":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2492","repository_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2492/labels{/name}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2492/comments","events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2492/events","html_url":"https://github.com/sonata-project/SonataAdminBundle/issues/2492","id":45723692,"number":2492,"title":"FosRestBundle braked SonataAdmin ajax call","user":{"login":"spolischook","id":1978331,"avatar_url":"https://avatars.githubusercontent.com/u/1978331?v=3","gravatar_id":"","url":"https://api.github.com/users/spolischook","html_url":"https://github.com/spolischook","followers_url":"https://api.github.com/users/spolischook/followers","following_url":"https://api.github.com/users/spolischook/following{/other_user}","gists_url":"https://api.github.com/users/spolischook/gists{/gist_id}","starred_url":"https://api.github.com/users/spolischook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spolischook/subscriptions","organizations_url":"https://api.github.com/users/spolischook/orgs","repos_url":"https://api.github.com/users/spolischook/repos","events_url":"https://api.github.com/users/spolischook/events{/privacy}","received_events_url":"https://api.github.com/users/spolischook/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-10-14T08:19:52Z","updated_at":"2016-02-14T09:13:59Z","closed_at":"2016-02-14T09:13:59Z","body":"When I try to submit popup with new entity, I get ajax error:\r\n- Status: parsererror \r\n- Error: SyntaxError: Unexpected token\r\n\r\nIt happens because, in my FosRestBundle config I have 'fallbackFormat' as 'json', so Symfony response set as 'application/json' and in body of response I have html.\r\nSo, I suggest:\r\n\r\n- Add log messages in all ajax calls for error event\r\n- Add 'dataType' attribute to all ajax calls that expect html in response\r\n\r\nIn our application I temporary fix in child of CRUDController:\r\n```php\r\npublic function render($view, array $parameters = array(), Response $response = null)\r\n    {\r\n        if (null === $response) {\r\n            $response = new Response();\r\n            $response->headers->set('Content-Type', 'text/html');\r\n        }\r\n\r\n        return parent::render($view, $parameters, $response);\r\n    }\r\n```\r\nnot the best solution, but it work."}}