79266693

Date: 2024-12-09 23:36:20
Score: 2
Natty:
Report link

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.

Reasons:
  • RegEx Blacklisted phrase (2.5): please post
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Kevin