Solved : Load a view dinamically with twig

I’m using version 3.12.1 with twig extension

I have a twig file with a form inside

the view is rendered via
$content = $this->_container->view->render($this->_response, $template, $context);

I load the form dinamically with (ajax) $("#div-form").load(/api/get/form)

but content contains also
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
<form …>

is there anyway to get only the form ?

is there anyway to get only the form ?

This should be the default behavior, if everything works fine.

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
<form …>

I would expect the headers to be in the response headers and not in the markup.

Do you have more code or a github repository?

Thanks for your reply it drive me to solution
after
$content = $this->_container->view->render($this->_response, $template, $context);

there is
die($content) it adds headers

if I
return $this->_container->view->render($this->_response, $template, $context);
the form is displayed fine