json-enc.js 360 B

123456789101112
  1. htmx.defineExtension('json-enc', {
  2. onEvent: function (name, evt) {
  3. if (name === "htmx:configRequest") {
  4. evt.detail.headers['Content-Type'] = "application/json";
  5. }
  6. },
  7. encodeParameters : function(xhr, parameters, elt) {
  8. xhr.overrideMimeType('text/json');
  9. return (JSON.stringify(parameters));
  10. }
  11. });