Where are you getting that output with such a simple echo… there is not even the need to set the layout=’’…
Layouts are displayed on RENDER… echo doesn’t affect… Make sure that you look at some kind of http request/response filter not on the firebug / chrome dev tools, as they tend to display formatted html page.
@vpk369: As said in the initial post, I tried to set $this->layout to none but it didn’t affect the output.
@Antonio Ramirez: I am well aware of the fact that echo and partialRender are not concerned by any kind of layout, but I was wondering that maybe there could be some default layout added in case the output was exempt of any html markup. I guess not…
As for the response in the browser, since the output is a response to an ajax call, it is not supposed to be rendered, thus I don’t expect it to be altered by the browser’s rendering engine or anything. Plus, I also modified the header in order to specify a json content, so the browser knows what it’s handling.
@jacmoe: the controller used to have the default layout but I created one simply echoing the $content and set it to be used by the controller. Anyway I am not using any render, only echo or renderPartial which are supposed to be raw output (layout-free).
As said in the answer to Antonio Ramirez, I changed the header and the browser noticed that it was some json content. Still the response contains html markup wrapped around my generated json.
To all: I am pretty sure that the browser is not involved because I changed my ajax call to a static html file containing the expect content (html-markup-free json), and it worked.
Thanks you all, I really do hope to find a solution to that issue since I’ve been on it for quite a few days.
I am currently working on a very heavy project, and we do a lot of AJAX-JSON related requests/responses and we do not have any issue at all and there is no html wrapped within it. There is no layout wrapping, nothing at all when you just echo from a controller’s action if you are not using render method…
Where do you see the code returned? On the browser? If ajax call THERE IS NO LAYOUTS if you just ECHO content, not basic ones… BUT, if you look at that action on a browser is obvious as the browser will set basic html as jacmoe already pointed.
Are you checking your AJAX calls with FIREBUG or CHROME console XHR requests? or just using the view code of the browser?
If you echo, there is no wrapping at all to blame Yii.
I’m sorry to look like a fool but yes I’m using Chrome’s XHR so I don’t think the browser adds any html. I tried to load a file containing no html and no html was present in XHR view. That’s why I’m still looking in Yii’s direction.