How to interrupt the asynchronous request of ajax or axios?

because when vue routes to a route, the data requested through ajax jumps to another routing page before it is returned, but the last axios asynchronous request is still being processed, so it does not meet expectations. How to deal with this situation?

Feb.27,2021

$.ajax has a return object on which you can call the abort method to cancel the request.


axios supports cancellation
axios document cancellation


since the ajax data is not returned, then either the ajax data is not returned, or the jump is performed after the ajax is completed.


shouldn't the real problem be to skip routing after asynchronous processing? How to become a discussion of how to cancel an ajax request.


you can use async/await asynchronous programming to handle
axios interception?
I think await can wait for async to return promise before processing the jump

Menu