mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 15:25:26 +00:00
Add support for 304
response code in addition to the 204
response code
This commit is contained in:
parent
278b5f1196
commit
d5f6ef2900
@ -1579,8 +1579,8 @@ return (function () {
|
|||||||
if (this.status === 286) {
|
if (this.status === 286) {
|
||||||
cancelPolling(elt);
|
cancelPolling(elt);
|
||||||
}
|
}
|
||||||
// don't process 'No Content' response
|
// don't process 'No Content' or 'Not Modified' response
|
||||||
if (this.status !== 204) {
|
if (this.status !== 204 && this.status !== 304) {
|
||||||
if (!triggerEvent(target, 'htmx:beforeSwap', eventDetail)) return;
|
if (!triggerEvent(target, 'htmx:beforeSwap', eventDetail)) return;
|
||||||
|
|
||||||
var resp = this.response;
|
var resp = this.response;
|
||||||
|
@ -240,6 +240,17 @@ describe("Core htmx AJAX Tests", function(){
|
|||||||
btn.innerHTML.should.equal("Click Me!");
|
btn.innerHTML.should.equal("Click Me!");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles 304 NOT MODIFIED responses properly', function()
|
||||||
|
{
|
||||||
|
this.server.respondWith("GET", "/test", [204, {}, "No Content!"]);
|
||||||
|
|
||||||
|
var btn = make('<button hx-get="/test">Click Me!</button>');
|
||||||
|
btn.click();
|
||||||
|
btn.innerHTML.should.equal("Click Me!");
|
||||||
|
this.server.respond();
|
||||||
|
btn.innerHTML.should.equal("Click Me!");
|
||||||
|
});
|
||||||
|
|
||||||
it('handles hx-trigger with non-default value', function()
|
it('handles hx-trigger with non-default value', function()
|
||||||
{
|
{
|
||||||
this.server.respondWith("GET", "/test", "Clicked!");
|
this.server.respondWith("GET", "/test", "Clicked!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user