Passing parameters via AJAX

Asked

Viewed 191 times

0

I am developing the part of customer registration in my application and is performing the registration in the database normally, but I would like that when I register and be redirected to page ConfirmacaoCadastro.jsp he took the email that I passed by parameter and put on the page but this is not happening.

AJAX

 function cadastrar(){


           $.ajax({  
type: "POST",  
url: "CadastroCliente",  
data: {
    nome: $("input[id=nome]").val(),
    cep: $("input[id=cep]").val(),
    celular: $("input[id=nr_celular]").val(),

    cpf: $("input[id=cpf]").val(),
    uf: $("input[id=uf]").val(),

    cidade: $("input[id=cidade]").val(),
    rua: $("input[id=rua]").val(),
    rg: $("input[id=rg]").val(),

    bairro: $("input[id=bairro]").val(),
    telefone: $("input[id=telefone]").val(),
    login: $("input[id=login]").val(),
   senha: $("input[id=senha]").val(),
    confirmar_senha: $("input[id=confirma_senha]").val(),
    data_nascimento: $("input[id=nascimento_dt]").val(),
     estado_civil: $("input[name='status']:checked").val(),
     sexo: $("input[name='sexo']:checked").val(),
     email: $("input[id=email]").val(),

},


success: function(result){   
 window.location.href = "ConfirmacaoCadastro.jsp?email="+email;

},
 error:function(){
     alert("erro");
        },
});

       } 

Confirmacaocadastro.jsp

           <div class="row">

           <div class="col-sm-4">

                       <h3> Confirmação de Cadastro </h3>

                        </div>


                                </div>

                                <div class="row">


                                    <div class="col-sm-4">

                                        <h4> Seus dados foram enviados para o email <p>${param.email}</p> </h4>

                                    </div>
                                </div>


                                         <div class="row">


                                    <div class="col-sm-4">

                                        <img src="imagens/voltaPagina.JPG" alt="voltarPaginaPrincipal" class="volta">

                                        <a href="index.jsp"> Voltar Pagina Principal</a>

                                    </div>
                                </div>

Page without e-mail passed by the parameter.

inserir a descrição da imagem aqui

1 answer

1


You are concatenating a variable that does not exist (email):

window.location.href = "ConfirmacaoCadastro.jsp?email="+email;

Declare the email variable with the email id input value:

success: function(result){
    var email = $("input[id=email]").val();
    window.location.href = "ConfirmacaoCadastro.jsp?email="+email;
}
  • our was just that, my inattention, thank you Samuel

  • there’s no point in thanking.. and I imagine you’re coding for many hours straight, it’s normal to give some kkkk panes

Browser other questions tagged

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