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')
?– Leonardo Santos
but where do you open the popup? is not in this code
– Ricardo Pontual
Oops, I forgot to put the div: <div id="vlrSimulacao"> </div>
– Gustavo Henrique de Faria