In this discusison, we can see the syntax for handling XMLHttpRequest and guarding against a wrong readyState and status combinations as follows.
if (request.readyState == 4 && request.status == 200) { ... }
I've always been using the conjunctive conditional trusting that both cases were independent allowing for all four combinations of the operational success when contacting a server.
Yesterday, I was thinking and it hit me that I can't explain what they might be. What are they?
- All dandy: readyState is done (4) and status is OK (200).
- Erroneous communication: readyState is done (4) and status isn't OK (!200).
- Not finished yet: readyState isn't done (!4) and status is OK (200).
- ?!?!?!?!: : readyState isn't done (!4) and status is OK (!200).
In particular, I don't get how something that's not finished can be both OK and not OK (cases 3 and 4). Shouldn't it always be status OK when not finished yet (or always status not OK)?!