You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you create a template file like my-ajax-handler.json.twig, Craft will automatically send a Content-Type: application/json header. No need for {% header ... %} tags in the template—just echo out the JSON!
This should work for any MIME type detectable via craft\helpers\FileHelper::getMimeTypeByExtension($template)—but please don't try and "render" an MP3 in Twig. :)
The text was updated successfully, but these errors were encountered:
Product
Craft CMS
Description
When you create a template file like
my-ajax-handler.json.twig
, Craft will automatically send aContent-Type: application/json
header. No need for{% header ... %}
tags in the template—just echo out the JSON!This should work for any MIME type detectable via
craft\helpers\FileHelper::getMimeTypeByExtension($template)
—but please don't try and "render" an MP3 in Twig. :)The text was updated successfully, but these errors were encountered: