Ajax get form data to compose in the url

0

I have an ajax call that needs to grab all form fields and post to a URL. My code looks 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 picking up the form fields, here is 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>

    
asked by anonymous 24.03.2016 / 16:38

1 answer

0

I found that you need to have name="nome of input "to get in $('#form_t').serialize()

    
24.03.2016 / 17:26