Is there an easy way to detect if an XMLHttpRequest is active in the browser window? Or how many are active? ie. Is there a way to detect if there are any AJAX calls active in my browser window?
Extension of question: Using javascript is there a way I can see if any XMLHttpRequests are open? Such as "window.XMLisActive()" or something like that?
Solution: Ended up writing a wrapper for XMLHttpRequest: gist here
There is not a way to detect an open connection from JS unless you write a wrapper for
XmlHttpRequest(or monkey patch it) that keeps track of opened connections.Here’s kidcapital’s monkey patch, not sure if it’s perfect, but it’s a good start
Note
This does not handle
fetchor websockets but you could do something similar in those cases.