0

In indexAction of my custom module's controller,

I have called loadlayout() and renderlayout(). I am now calling an ajaxAction through ajax from a template file. Do I need to use loadlayout() again?

Should it be loadlayout(false)?

Edit: I intend to display a list of products through AJAX; I have created block and template files for AJAX and added code in the layout file under tag.

  • from ajaxAction what u want to repose? – Amit Bera Jan 4 '16 at 17:41
  • @AmitBera, I've edited the question details to answer your query. – Prateek Jan 4 '16 at 20:19
2

Depends what's the response of your AJAX action. If you defined a layout handle for it (<custom_controller_ajax>), load and render it. Of course the handle must have different content than the one for the non-ajax action:

Set the "empty" page layout instead of "1column" etc., or define a different root block.

If you don't use the layout to render your response, then don't call loadLayout(). This is for example if you create a JSON response.

| improve this answer | |
  • Hi, I have added question to add more details. I am using the layout file. So, would I use loadlayout(false)? since I have already loaded all JS/CSS, etc. in index action? – Prateek Jan 4 '16 at 20:26
  • what is good expatiation @fschmengler – Amit Bera Jan 5 '16 at 2:34
0

Every controller action has an associated layout handle and the handle is a string which relates to the module, the controller and the action for the current request (and is therefore unique to requests which reach that action). When you load and then render the layout in the controller action, all of the blocks for that handle are rendered out to create the page.

First of all check what the layout handle is for the request? If it is from xml you should use loadLayout().

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.