E o AJAX com Harbour é possivel ?

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7928
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

E o AJAX com Harbour é possivel ?

Mensagem por Itamar M. Lins Jr. »

Ola!

AJAX is a developer's dream, because you can:
  • Update a web page without reloading the page
    Request data from a server - after the page has loaded
    Receive data from a server - after the page has loaded
    Send data to a server - in the background
Porque não ?

Arquivo: gethint.prg

Código: Selecionar todos

#!/usr/local/bin/hbrun         
Function Main(...)
LOCAL cEOL := hb_eol() + hb_eol()
OutStd("Content-type: text/html" + cEOL )
OutStd("Maria" + hb_eol() )
RETURN ""
Arquivo: testeajax.html

Código: Selecionar todos

<html>
<head>
<script>
function showHint(str) {
    if (str.length == 0) {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("txtHint").innerHTML = this.responseText;
            }
        };
        xmlhttp.open("POST", "cgi-bin/gethint.prg", true);
        xmlhttp.send();
    }
}
</script>
</head>
<body>

<p><b>Start typing a name in the input field below:</b></p>
<form>
First name: <input type="text" onkeyup="showHint(this.value)">
</form>
<p>Suggestions: <span id="txtHint"></span></p>
</body>
</html> 
Para quem não está entendendo, usando AJAX é possível abrir a comunicação com servidor e fazermos um VALID igual no Harbour/Clipper em um <input> a famoso GET-READ do harbour/clipper.

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Responder