hx-headers

hx-headers 属性允许你添加到将随 AJAX 请求提交的标头。

¥The hx-headers attribute allows you to add to the headers that will be submitted with an AJAX request.

默认情况下,此属性的值是 JSON(JavaScript 对象表示法) 格式的名称表达式值列表。

¥By default, the value of this attribute is a list of name-expression values in JSON (JavaScript Object Notation) format.

如果你希望 hx-headers 评估给定的值,则可以在值前加上 javascript:js:

¥If you wish for hx-headers to evaluate the values given, you can prefix the values with javascript: or js:.

  <div hx-get="/example" hx-headers='{"myHeader": "My Value"}'>Get Some HTML, Including A Custom Header in the Request</div>

  <div hx-get="/example" hx-headers='js:{myVal: calculateValue()}'>Get Some HTML, Including a Dynamic Custom Header from Javascript in the Request</div>

安全注意事项

¥Security Considerations

注释

¥Notes