diff --git a/www/content/attributes/hx-vals.md b/www/content/attributes/hx-vals.md index ebe02852a..1cb7f42ff 100644 --- a/www/content/attributes/hx-vals.md +++ b/www/content/attributes/hx-vals.md @@ -33,6 +33,36 @@ You can also use the spread operator to dynamically specify values. This allows In this example, if `foo()` returns an object like `{name: "John", age: 30}`, both `name` and `age` will be included as parameters in the request. +## Using hx-vals with hx-post + +The `hx-vals` attribute works with all HTTP methods, including `hx-post`, `hx-put`, `hx-patch`, and `hx-delete`: + +```html + +``` + +When used with non-GET requests (POST, PUT, PATCH, DELETE), the values from `hx-vals` are included in the request body. +When used with GET requests, they are appended as query parameters. + +## JSON Syntax Requirements + +The `hx-vals` attribute requires **valid JSON syntax**. A common mistake is using single quotes inside the JSON, which will cause the values to be silently ignored: + +```html + +