Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  88] [ 7]  / answers: 1 / hits: 34090  / 8 Years ago, sat, february 27, 2016, 12:00:00

I want to cancel the ajax request from chrome developer tools after it has initiated. For example I want to test my fallback message is showing correctly. I can set No throttling to Offline so that all calls will fail, but I just want to test one API to fail, for debugging purposes.



Developer



I know I can use abort() methods, (ie I can do it through JavaScript). I dont want to touch the code for just this need.



There's a replay XHR option in right click of the API, It'll be great there is something like abort XHR in same way. But there isn't.


More From » ajax

 Answers
9

From Chrome 59 you can block specific requests from Network tab of developer tools itself.



https://developers.google.com/web/updates/2017/04/devtools-release-notes#block-requests



Right-click on the request in the Network panel and select Block Request URL. A new Request blocking tab pops up in the Drawer, which lets you manage blocked requests.



So, In my case, I will run the code block that specific API and then re-run. :)



As per the comment, this is not exactly canceling the already started request, but checking how the app behaves if only one request is failed by blocking only one request. Thanks @Ross Ivantsiv for this.



screenshot


[#63136] Thursday, February 25, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
willieelisham

Total Points: 201
Total Questions: 108
Total Answers: 106

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
;