0
I have an ajax call that needs to take all the form fields and post to a URL. My code is like this:
<script>
$(document).ready(function() {
$('#somebutton').click(function(event) {
var valorAplicado=$('#valorAplicado').val();
$('#somediv').html('');
$('#somediv').html('<center><img src="images/aguarde.gif" width="60" height="60" alt="Aguarde" class="loading"></center>');
$.get('http://www.endereco.com.br/Simulacao2',$('form_t').serialize(),function(responseText) {
if(responseText) {
$('#somediv').html('<center><img src="images/aguarde.gif" width="60" height="60" alt="Aguarde" class="loading"></center>');
$('#somediv').html("<html>" +responseText+ "</html>" );
window.scrollTo(5000,document.body.scrollHeight);
}else{
//alert("Error");
}
//$('#somediv').html(responseText);
});
});
});
But you are not taking the form fields, follow form code:
<form id="form_t" name="form_t" class="col s12" method="post">
<div class="row">
<div class="input-field col s12">
<input id="aplicacao" class="validate" type="text" value="1000">
<label class="active" for="aplicacao">Aplicação:</label>
</div>
<div class="input-field col s12">
<input id="aplicacao" class="validate" type="text" value="24">
<label class="active" for="aplicacao">Período (meses):</label>
</div>
There’s no missing one
#
here:$('form_t').serialize()
?– Sergio