Back to Practical Aspnetcore

Using hx-vals on all HTTP verbs

projects/htmx/hx-vals/README.md

latest679 B
Original Source

Using hx-vals on all HTTP verbs

This example shows how to use hx-vals to pass parameters to all supported HTTP verbs (doc)

html
    <ul>
        <li hx-get="/htmx" hx-vals='{"Name": "Anna"}'>GET</li>
        <li hx-post="/htmx" hx-vals='{"Name": "Anna"}'>POST</li>
        <li hx-put="/htmx" hx-vals='{"Name": "Anna"}'>PUT</li>
        <li hx-patch="/htmx" hx-vals='{"Name": "Anna"}'>PATCH</li>
        <li hx-delete="/htmx" hx-vals='{"Name": "Anna"}'>DELETE</li>
    </ul>

On GET and DELETE, the parameters are accessible via Request.Query. For the rest, you can access the parameters via Request.Form.