0

Javascript to get the number of Ajax request that are ongoing in the current page? I am using "Jquery.active", which is returning "0" even though there is a ongoing request.

  • When do you return that? It is asynchronous. – deEr. Apr 09 '18 at 10:40
  • how is a property asynchronous @AjAX.? that makes no sense – Jaromanda X Apr 09 '18 at 10:43
  • I've read in a 8 year old post that `jQuery.active` "will become" `jQuery.ajax.active` - so, I guess the question is, which version of jQuery are you using – Jaromanda X Apr 09 '18 at 10:44
  • According to [this post](https://stackoverflow.com/a/3148506/6009304), `jquery.active` became `jquery.ajax.active`. The post is from 2010 so I suspect that has already been done. Also, a comment from 2013 in the [post](https://stackoverflow.com/questions/3148225/jquery-active-function/3148506#comment25407244_3148506) says it is now `$.active`. – Tyler Apr 09 '18 at 10:45
  • The jQuery version used on SO — 1.12.4. — has `$.active` and `jQuery.active`. It is — not — `jQuery.ajax.active`. It is important to call at the right moment @JaromandaX. Because the whole `AJAX` thing is asynchronous. – deEr. Apr 09 '18 at 11:00
  • yes, but the value of `jQuery.active` is not *asynchronous* – Jaromanda X Apr 09 '18 at 11:11
  • Yes @JaromandaX, The value i.e returned when I execute the command jQuery.active is not asynchronous. – samurai Apr 09 '18 at 11:52
  • I need the command/JS code that returns the counts or the "true" or "false" if there are any AJAX calls are happening at the time when I execute this command/JS in the browser. Can You Please help me in getting it. I am new to JavaScript world – samurai Apr 09 '18 at 11:54
  • Your command is nearly right. Do you know about the `console`? In Chrome it is right click and `Inspect`. Then `console`. There you can output from your JS code like `console.log('lineNumberInCode', jQuery.active)`. Have joy. – deEr. Apr 09 '18 at 14:57

0 Answers0