Display the AJAX result in a popup

Asked

Viewed 25 times

1

I am trying to run a function that will send data from a form to a server and bring a response to the user in a popup with CSS styles.

I’m not able to display this popup with the result.

<script type="text/javascript">



    function simulacao(nome, email, qtdMeses, vlrAluguel){

        $.ajax({
            url: url + "/api/simulacao",
            type: "POST",
            data: {nome, email, qtdMeses, vlrAluguel},
            dataType: "json",
            cache: false,
            success: function (data) {
                if(data.Status == "ok"){

                    $('#vlrSimulacao').text("Você pode receber até R$ " + data.Result);
                }
            }           
        });
    }

    $(function(){

        $("#nf-field-2").click(function(){              
            if($("[name='nome']").val() != ""
            && $("[name='email']").val() != ""
            && $("[name='nf-field-5']").val() != ""
            && $("[name='nf-field-4']").val() != ""){
                simulacao($("[name='nome']").val(), $("[name='email']").val(), $("[name='nf-field-5']").val(), $("[name='nf-field-4']").val());
            }
        });

    });

  • Have you seen if there are any errors in the console? The popup would be the $('#vlrSimulacao')?

  • but where do you open the popup? is not in this code

  • Oops, I forgot to put the div: <div id="vlrSimulacao"> </div>

No answers

Browser other questions tagged

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