Wait for ajax requests?



Is is possible to wait for ajax requests, like jQuery.post function for example?

Best regards


There are two Katalon APIs which are meant to aid with ajax, but since they check load state, they may not help much with inline XHR requests:


However, there is a jQuery internal variable, jQuery.active which you can check. It is a counter that returns to zero when all jQuery XHR requests are finished. You can use JavaScript to check its value.

@“Katalon Team” there should be a WebUI API that specifically waits for that variable to return to zero.

Take care that you don’t try to check it too soon after whatever event is meant to trigger the XHR request. Add a one second delay prior to checking it using WebUI.delay(1) or similar.

For reference, here is a link to the jQuery source:


Thanks Russ. That could work fine. I am just hoping that I don’t come across pages don’t do ajax requests without jQuery but instead use pure JS (XMLHttpRequest)

Best regards


Sorry, Ismar, I meant to add that to the post – that it’s almost as easy to do it in pure JS. The host will need to implement a counter similar to jQuery.active (XHR.active perhaps).

Thanks for the BA B)