Problems to create perfect content representation for ajax

I try to use the content representations for my AJAX solution.
But know I try to send also directly the html to get all the logic parts done by PHP but without the unnecessary snippets like menu or header.
But if I load it with the suffix .html.php the link loads the normal php-template with the complete stuff and not only the content representation. To transfer the html as JSON is also not really nice because I have to write the complete code in a variable and than I have problems with foreach loops.
If I send it as a txt-file the php-part will not be rendered.

So what is now the easiest and best way to get a template without snippets but with html and all the php-stuff rendered and transfered for ajax?

Best regards

Same as here, you send it as json encoded array, where one (or the only) key contains the html: Load more with Ajax | Kirby CMS

But I don’t see why you should be able to encode the HTML as JSON.

1 Like

thanks! This cookbook explain it really good how to use the snippet to load html in a JSON-object.