Ajax Status

XMLHttpRequest Object Properties

ajax-9-638

if (window.XMLHttpRequest) {
            xhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        //O QUE SERÁ ALTERADO NA PAGINA
        xhttp.onreadystatechange = function () {
            if ((this.readyState === 0)){
                alert("0: request not initialized ");           
            }
            else if ((this.readyState === 1)){
                alert("1: server connection established");
            }
            
            else if ((this.readyState === 2)){
                alert("2: request received ");
            }
            
            else if ((this.readyState === 3)){
                alert("3: processing request ");
            }
            
            else if ((this.readyState === 4)){
                alert("4: request finished and response is ready");
                document.getElementById("listaResultadoCurso").innerHTML = this.responseText;
            }
            
            else if (this.status === 200) {
                alert("200: OK");
            }
        else if (this.status === 403) {
                alert("403: Forbidden");
            }
            
            else if (this.status === 404) {
                alert("404: Not Found");
            }
        else {
                alert("Nenhuma das Alternativas");
            }
        };