defunkt / jquery-pjax

pushState + ajax = pjax
https://pjax.herokuapp.com
MIT License
16.73k stars 1.97k forks source link

pushState() still occurs when returning false in pjax:error event #661

Open nickelfault opened 7 years ago

nickelfault commented 7 years ago

When an ajax request fails and you return false in the pjax:error event, I don't think pushState() should still be executed. When this happens you end up with an incorrect URL in the address bar. In my case, on a failure I display an alert to the user (404 not found, etc). In this case the user ends up with an inconsistent state, they see different content than the URL should provide, and if they refresh the page they'd get a whole new set of content. I've submitted a pull request that fixes the problem for me, not sure if you'd want to merge it or not.

660