瀏覽代碼

had to update a js file

AETH-erial 6 月之前
父節點
當前提交
48cd169462
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      html/htmx/json-enc.js

+ 12 - 1
html/htmx/json-enc.js

@@ -1 +1,12 @@
-Found. Redirecting to /htmx.org@1.9.10/dist/ext/json-enc.js
+htmx.defineExtension('json-enc', {
+    onEvent: function (name, evt) {
+        if (name === "htmx:configRequest") {
+            evt.detail.headers['Content-Type'] = "application/json";
+        }
+    },
+    
+    encodeParameters : function(xhr, parameters, elt) {
+        xhr.overrideMimeType('text/json');
+        return (JSON.stringify(parameters));
+    }
+});