How to load value from a variable through Ajax

1

I've done the following in an html file:

    <script>
    //transmite as informações
    var xmlHttp = GetXmlHttpObject();
    function show() {
        if (xmlHttp == null) {
            alert ("Seu browser não suporta AJAX!");
            return;
        }else{
            var url = "pagina.html";  //pagina que contem apenas uma frase simples sem formatação
            xmlHttp.onreadystatechange = stateChanged;
            xmlHttp.open("POST",url,true);
            xmlHttp.send(null);
        }
    }        

    //verifica o status do carregamento da pagina
    function stateChanged() {
        if (xmlHttp.readyState==4) {
            document.getElementById("texto").innerHTML=xmlHttp.responseText;
        }
    }

    //pega o objeto xmlHTTP do navegador
    function GetXmlHttpObject() {
        var xmlHttp = null;
        try {
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer
            try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
       }
        return xmlHttp;
    }

    window.setInterval(show, 10000);
    </script>
    </head>
    <body>
    <div id="texto"></div>
    <script>show();</script>
    </body>
    </html>

So I would like to capture a value from a local variable within the same script instead of going into another file to fetch such information.

Who can help thank you

    
asked by anonymous 17.11.2016 / 18:15

0 answers