Coder Social home page Coder Social logo

Comments (3)

Telroshan avatar Telroshan commented on July 24, 2024 1

Weird, I don't experience the same behavior, see this JSFiddle where it acts as you would expect...
image

The part of the code that's responsible to determine whether the request is an error or not relies on the htmx2-introduced responseHandling property ;

htmx/src/htmx.js

Lines 264 to 268 in 6f83885

responseHandling: [
{ code: '204', swap: false },
{ code: '[23]..', swap: true },
{ code: '[45]..', swap: false, error: true }
],

That's the default configuration, which sets error to true for any 4xx or 5xx code. Later on, this value is used to determine whether the request is successful, or a failure, as so :

htmx/src/htmx.js

Lines 4606 to 4608 in 6f83885

const responseHandling = resolveResponseHandling(xhr)
const shouldSwap = responseHandling.swap
let isError = !!responseHandling.error

Did you modify that property by any chance and maybe forgot to set error to true for the 400 code ?
Let me know!

from htmx.

schungx avatar schungx commented on July 24, 2024 1

@Telroshan Thank you for the quick response! You are correct of course. It’s a behaviour of the Response Targets extension and fixed by setting htmx.config.responseTargetUnsetsError = false:

Yup. Tripped me up exactly the same way, but you found out before I can post an answer.

from htmx.

JanRomero avatar JanRomero commented on July 24, 2024

@Telroshan Thank you for the quick response! You are correct of course. It’s a behaviour of the Response Targets extension and fixed by setting htmx.config.responseTargetUnsetsError = false:

https://jsfiddle.net/34wtxzh5/1/

Honestly I love HTMX but its weird defaults drive me nuts sometimes.

Thanks!

from htmx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.