XF 2.0 Pass array to template via ajax

S Thomas

Well-known member
I'm trying to pass an array to a template via ajax and then display that template. Basically what I want is the rendered template without page container and all that stuff, just the plain template so I can show that in another already fully rendered page. Like this: https://xenforo.com/community/threads/return-content-without-pagecontainer.33902/ or https://xenforo.com/community/threads/using-an-alternative-page-container.11465/
What I've tried so far is to set response type to raw in my controller and render the output template in the view. That works, but it adds "" around the content and I don't know why, so the output looks like "test".
What is the correct approach here? Or how can I get rid off those ""?
tl;dr:
Ajax calls this controller method:
PHP:
$this->setResponseType('raw');
(...)
return $this->view('Test\TestAddon:Test\TestView', 'test_results', $viewParams);
view:
PHP:
public function renderRaw()
    {
        return $this->renderTemplate("public:test_results", $this->params);
    }
Thanks for any help.
 
Last edited:
Top Bottom