Try removing hx-post="slacktest/ui" hx-swap="outerHTML"
from your form
element, and updating your button
to:
<button type="button" class="btn btn-primary" hx-post="slacktest/ui" hx-swap="outerHTML" hx-target="#counter"> Click me </button>
This is because, by default a button
on a form
is of type submit
, and submit
defaults to a GET
request if the url is defined on the form...
Your HTMX
is intercepting the form
submission payload, but not the submit
execution. By defining the button
as type button
you are now intercepting the default execution, and the hx-post
and hx-target
are intercepting the payload.
If this still doesn't work, please post the body of your program.cs which contains your APIs.