Listen "The basics: hx-post"
Episode Synopsis
Want to use POST requests in ajax, and submit forms from anywhere on the page?As promised in the episode, here are three ways to set up your CSRF token headers:1. Like normal in your forms:<input type="hidden" name="_token" value=""/> (the regular html way works with htmx, of course)2. Javascript<script>document.body.addEventListener('htmx:configRequest', (e) => { e.detail.headers['X-CSRFToken'] = '';})</script>(add this to the bottom of your </body> so that EVERY request gets the right headers. I love this one!)hx-headers<div hx-post="/your-endpoint" hx-headers='{"X-CSRF-Token": "YourCSRFTokenHere"}'> <!-- Your content --> </div>(add this attribute along with your hx-post)
More episodes of the podcast hx-pod
Thinking strategically about your career
04/11/2025
Hypermedia in the wild
26/09/2025
3d and flappy bird htmx
05/09/2025
Htmx extension: response-targets
29/08/2025
Big Sky Dev Con 2025
19/08/2025
Htmx extension: preload
07/08/2025
Htmx extension: idiomorph
01/08/2025
Htmx extension: htmx-1-compat
30/07/2025
Htmx extension: head-support
28/07/2025
ZARZA We are Zarza, the prestigious firm behind major projects in information technology.