miguel-perez / smoothState.js

Unobtrusive page transitions with jQuery.
MIT License
4.43k stars 508 forks source link

Build in Support for HTTP status codes and Error Handling #351

Open shoes22 opened 6 years ago

shoes22 commented 6 years ago

I've implemented Smoothstate into our platform, and for the most part it works very well after incorporating a few jquery hacks to not break any existing site functionality. What I would like to have as a native feature in smoothstate is built-in error handling conditions for ajax requests. For example, if the HTTP status code of the requested page is anything besides 200, (like 404, 500, etc.), then allow smoothstate to stop loading the new page, and execute other code instead (like an error message).

In the current behavior, when smoothstate encounters an error, the page will just hang and remain in the loading state indefinitely.

extricate commented 6 years ago

Definitely support this (came here looking for something like this); might however end up simply writing this myself.

rupl commented 5 years ago

Having an onError handler would be nice especially for responses like 401/403 where you'd ideally like to transition somewhere, offer an informative message, and maybe a back button.

extricate commented 5 years ago

@rupl I think by now we ought to move on to bigger and better things, considering this package has basically been unmaintained for at least 3 - 4 years now. Have you met my friend React.JS?

rupl commented 5 years ago

@extricate yes I agree for new projects I reach for a completely different toolset. However I often work on projects that have legacy codebase. In this case, I don't have authorization to rewrite the whole thing, you know?

I do perceive this library to be unmaintained, but still worth bumping, if only so I can link here within my own code comments and explain my actions (e.g. serving a 200 on what should be a 401 so I can get the thing to work)

extricate commented 5 years ago

@rupl Fair point. Good luck with the legacy then!