Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Pending AJAX requests or HTTP GET/POST request

How do i check if the page has pending AJAX or HTTP GET/POST requests? I use javascript and/or python for this checking.

what i wanted to do is execute a script if a page has finished all requests. onload doesn't work for me, if you used firebugs net panel, you would know. onload fires when the page is loaded but there is a possibility that there are still pending request hanging around somewhere.

thank you in advance.

like image 763
klambiguit Avatar asked Jul 16 '10 06:07

klambiguit


People also ask

Does AJAX use post or GET?

jQuery - AJAX get() and post() Methods. The jQuery get() and post() methods are used to request data from the server with an HTTP GET or POST request.

What is the difference between AJAX request and HTTP request?

AJAX stands for asynchronous javascript and XML so if you are using javascript to load data after the browser request has finished you are doing AJAX. REST on the other hand stands for Representational State Transfer which as Stefan Billet pointed out uses HTTP requests to transfer data.

Is AJAX an HTTP request?

An AJAX request is a request made by an AJAX application. Typically, it is an HTTP request made by (browser-resident) Javascript that uses XML to encode the request data and/or response data.


2 Answers

figured it out. thanks for the effort guys. just plain and simple javascript.

interValRef = 0;

interValRef = setInterval("checkState();",100)

function checkState(){
    if(document.readyState == 'complete'){
        clearInterval(interValRef);
        myFunc();
    }
}
like image 132
klambiguit Avatar answered Sep 18 '22 16:09

klambiguit


Here is the best way of checking it.

var loadingDone =  document.readyState=="complete" && jQuery.active === 0;

So loadingDone will be true, if Ajax calls are done. If its false then you can add waiting.

like image 25
user8462556 Avatar answered Sep 17 '22 16:09

user8462556