diff --git a/src/htmx.js b/src/htmx.js index 5b7795f5c..b6b761981 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -3302,8 +3302,7 @@ return (function () { }); }); triggerEvent(elt, 'htmx:beforeSend', responseInfo); - var userSetContentType = (etc.headers && etc.headers['Content-Type']); - var params = useUrlParams ? null : !userSetContentType ? encodeParamsForBody(xhr, elt, filteredParameters) : etc.values; + var params = useUrlParams ? null : encodeParamsForBody(xhr, elt, filteredParameters); xhr.send(params); return promise; } diff --git a/test/core/api.js b/test/core/api.js index 916ae3a44..dd88695be 100644 --- a/test/core/api.js +++ b/test/core/api.js @@ -272,9 +272,9 @@ describe("Core htmx API test", function(){ it('ajax api Content-Type header override to application/json', function(){ this.server.respondWith("POST", "/test", function (xhr) { + var params = getParameters(xhr); xhr.requestHeaders['Content-Type'].should.equal('application/json;charset=utf-8'); - const requestBody = JSON.parse(xhr.requestBody); - chai.expect(requestBody.grug).to.be.equal("brain"); + params['i1'].should.equal("test"); xhr.respond(200, {}, "Clicked!"); }); @@ -285,7 +285,7 @@ describe("Core htmx API test", function(){ headers: { 'Content-Type': 'application/json' }, - values: '{"grug":"brain"}' + values:{i1: 'test'} }) this.server.respond();