HTMX AJAX ¶
Introduction ¶
The core of htmx is a set of attributes that allow you to issue AJAX requests directly from HTML.
HTMX Attribute |
Description |
---|---|
Issues a GET request to the given URL |
|
Issues a POST request to the given URL |
|
Issues a PUT request to the given URL |
|
Issues a PATCH request to the given URL |
|
Issues a DELETE request to the given URL |
Each of these attributes takes a URL to issue an AJAX request to. The element will issue a request of the specified type to the given URL when the element is triggered :
<div hx-put="/messages">
Put To Messages
</div>
This tells the browser: When a user clicks on this div, issue a PUT request to the URL /messages and load the response into the div.
MDN HTTP methods documentation ¶
-
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
-
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
-
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
-
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
-
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE