Problem in the arrival of information by AJAX

Asked

Viewed 32 times

0

I have the problem with the ajax request. I can send the information, but when it arrives in the other page the message appears

[Object Htmlinputelement]

I can’t understand. He sent an object?

// função que recebe o evento do javascript onkeyup
function verificaEmail(x){
            var conectarServidor = iniciarAjax();
            if (conectarServidor) {
                conectarServidor.onreadystatechange = function() {
                    if (conectarServidor.readyState == 4) {
                        if (conectarServidor.status == 200) {
                            document.getElementById("comparaEmail").innerHTML = this.responseText;

                    }   else {
                            alert("O sistema não está funcionando corretamente! ");
                        }
                    }
                }
                conectarServidor.open("POST", "http://127.0.0.1:8080/locadora/cadastro.php?q="+email,true);
                conectarServidor.send();
            }
        }   
// até aqui tudo bem. Mas quando chega na outra página aparece essa mensagem.

    $conexao = mysqli_connect("localhost","root","123","locadora");
        $email = $_REQUEST["q"];
        $sql = "select*from cliente where email='email'";
        $rs = mysqli_query($conexao,$sql);
        $result = mysqli_num_rows($rs);
         // abaixo eu fiz uma condição para saber se exite o email.
         // aquela mensagem só apareceria se eu escrevesse echo $email.
        if($result >="1"){
           echo "usuário já cadastrado."
        }
        else{
         echo "";
           }
  • "He sent an object?" - Yes, HTMLInputElement is an object representing the field <input> from the form. You can obtain information from this object by accessing its properties: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement

  • I managed to solve it. Thank you. The problem was in the function parameter. In the input tag I put a function with the onkeyup event. Only at the time, I didn’t send anything. That’s why this problem appeared. I had to put this.value. Ex onkeyup=verificaEmail(this.value);

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.