Disabling layout for AJAX module
How can I disable the layout for AJAX module? I have crated the module and tried to add the entry to view.yml referring to the module as ajax:, but it didn't work. Currently, I use $this->setLayout(false), which is not really nice... Also, according this do开发者_如何学Cc, view.yml is deprecated.
You shouldn't need to. XHR requests are automatically rendered without layout.
About your question roman about how symfony recognize that it's a XHR. there is a function that you can use in symfony that tests the requests against that. It goes like the following
$request->isXmlHttpRequest()
this return true if the request came from an ajax call. very helpful function when making an action for ajax calls and when you want it to only respond to ajax calls.
精彩评论