diff --git a/src/ext/json-enc.js b/src/ext/json-enc.js index 76ca75f8..eb76bdc0 100644 --- a/src/ext/json-enc.js +++ b/src/ext/json-enc.js @@ -1,7 +1,12 @@ htmx.defineExtension('json-enc', { + onEvent: function (name, evt) { + if (name === "configRequest.htmx") { + evt.detail.headers['Content-Type'] = "application/json"; + } + }, + encodeParameters : function(xhr, parameters, elt) { - xhr.setRequestHeader('Content-Type', 'application/json'); xhr.overrideMimeType('text/json'); return (JSON.stringify(parameters)); } -}); +}); \ No newline at end of file diff --git a/www/attributes/hx-sse.md b/www/attributes/hx-sse.md index 0b77e1d1..c9e95735 100644 --- a/www/attributes/hx-sse.md +++ b/www/attributes/hx-sse.md @@ -18,7 +18,7 @@ Here is an example: ```html