Stop ajax loading with `esc`
See original GitHub issueCurrent
- Click on the “Issues” tab above
- Change your mind
- Can’t do anything, Issues keeps loading
- When loaded, go back
Desired
- Click on the “Issues” tab above
- Change your mind
- Press
esc
, loading stops
⬆️ this is how regular pages work, but pjax
doesn’t listen to esc
IssueHunt Summary
artusm has been rewarded.
Backers (Total: $40.00)
- issuehunt ($40.00)
Submitted pull Requests
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:25 (15 by maintainers)
Top Results From Across the Web
Abort AJAX file upload by pressing escape key - Stack Overflow
I'm trying to abort() an AJAX file upload. I've tried adding event listeners and am trying to abort() for any keypress at all...
Read more >Problem with Ajax Request and Escape - jQuery Forum
In most browsers esc stops page loading, in the event of ajax, it aborts the loading. This is just a shot in the...
Read more >Firefox abort all AJAX request when you press ESC
Why firefox abort all AJAX request when you press the ESC button? I don't see any value in a feature like this.
Read more >Google May Stop Crawling Old AJAX Scheme With Escape ...
As you know, Google deprecated their old AJAX crawling scheme proposal just about two years ago. But currently they still do crawl and...
Read more >How to avoid unwanted clicks while processing an AJAX request
My solution to this is to define a boolean such as bRequestActive and set it to true as soon as the request goes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not sure if https://github.com/defunkt/jquery-pjax is the one GitHub is using, because most of the events are missing from GitHub’s JS files.
So, I came up with a hack using
AbortController
, that involves replacingfetch
at global level.One catch with the above snippet is that after the fetch is aborted, the user is directly redirected to the target page, which is no the intended behavior, we need the user to stay on the current page.
I think we can manage this using as very clever combination of
mousedown
,click
, andmouseup
event handlers and usingstopPropagation()
if the click actually caused that aborted fetch (haven’t tested that part though).From “impossible” to “done”
Thanks @artusm!