Skip to main content
removeu 1881 caracteres do conteúdo
Fonte Link
William
  • 627
  • 1
  • 6
  • 20
  <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>
<div class="input-field col s12">
  <input id="taxa_selic" class="validate"  type="text" value="10">
  <label class="active" for="taxa_selic">Taxa Selic (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="100">
  <label class="active" for="di">DI (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="10">
  <label class="active" for="di">Taxa ADM (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="10">
  <label class="active" for="di">Tesouro Direto (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="cdb" class="validate" type="text" value="100">
  <label class="active" for="cdb">CDB/LC/RDB (DI):</label>
</div>
<div class="input-field col s12">
  <input id="lci" class="validate" type="text" value="100">
  <label class="active" for="lci">LCI/LCA (DI)</label>
</div>

<div class="row"> 
  
  <!-- Modal Trigger -->
  <div class="input-field col s12">
    <button type="submit" id="somebutton" name="somebutton"  class="btn-floating btn-large red right modal-trigger" href="#modal1"  > <i class="mdi-content-send right"></i> </button>
    
    
  </div>
</div>

<!-- Modal Structure -->
<div id="modal1" class="modal">
  <div class="modal-content">
    <div class="col s12">
      <ul class="collection with-header">
        
        <div id='somediv' ></div>
        <div  class='inset'   >
          <div id="pai"; style="display: none;" class='message success'> </div>
        </div>
        
      </ul>
    </div>
  </div>
</div>
  <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>
<div class="input-field col s12">
  <input id="taxa_selic" class="validate"  type="text" value="10">
  <label class="active" for="taxa_selic">Taxa Selic (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="100">
  <label class="active" for="di">DI (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="10">
  <label class="active" for="di">Taxa ADM (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="10">
  <label class="active" for="di">Tesouro Direto (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="cdb" class="validate" type="text" value="100">
  <label class="active" for="cdb">CDB/LC/RDB (DI):</label>
</div>
<div class="input-field col s12">
  <input id="lci" class="validate" type="text" value="100">
  <label class="active" for="lci">LCI/LCA (DI)</label>
</div>

<div class="row"> 
  
  <!-- Modal Trigger -->
  <div class="input-field col s12">
    <button type="submit" id="somebutton" name="somebutton"  class="btn-floating btn-large red right modal-trigger" href="#modal1"  > <i class="mdi-content-send right"></i> </button>
    
    
  </div>
</div>

<!-- Modal Structure -->
<div id="modal1" class="modal">
  <div class="modal-content">
    <div class="col s12">
      <ul class="collection with-header">
        
        <div id='somediv' ></div>
        <div  class='inset'   >
          <div id="pai"; style="display: none;" class='message success'> </div>
        </div>
        
      </ul>
    </div>
  </div>
</div>
  <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>
removeu 151 caracteres do conteúdo
Fonte Link
William
  • 627
  • 1
  • 6
  • 20
<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);
                    scrolldown();
                    desce_scroll();
                }else{
                     //alert("Error");
                 }
                    //$('#somediv').html(responseText); 
                    scrolldown();
                    window.scrollTo(10000,document.body.scrollHeight);
                    desce_scroll();
                });
            });
        });
<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);
                    scrolldown();
                    desce_scroll();
                }else{
                     //alert("Error");
                 }
                    //$('#somediv').html(responseText); 
                    scrolldown();
                    window.scrollTo(10000,document.body.scrollHeight);
                    desce_scroll();
                });
            });
        });
<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); 
                });
            });
        });
Fonte Link
William
  • 627
  • 1
  • 6
  • 20

Ajax pegar dados do formulário para compor na url

Tenho uma chamada ajax que precisa pegar todos os campos do formulário e postar em uma URL. Meu código está assim:

<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);
                    scrolldown();
                    desce_scroll();
                }else{
                     //alert("Error");
                 }
                    //$('#somediv').html(responseText); 
                    scrolldown();
                    window.scrollTo(10000,document.body.scrollHeight);
                    desce_scroll();
                });
            });
        });

Porém não está pegando os campos do formulário, segue código do form:

  <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>
<div class="input-field col s12">
  <input id="taxa_selic" class="validate"  type="text" value="10">
  <label class="active" for="taxa_selic">Taxa Selic (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="100">
  <label class="active" for="di">DI (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="10">
  <label class="active" for="di">Taxa ADM (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="di" class="validate" type="text" value="10">
  <label class="active" for="di">Tesouro Direto (%a.a):</label>
</div>
<div class="input-field col s12">
  <input id="cdb" class="validate" type="text" value="100">
  <label class="active" for="cdb">CDB/LC/RDB (DI):</label>
</div>
<div class="input-field col s12">
  <input id="lci" class="validate" type="text" value="100">
  <label class="active" for="lci">LCI/LCA (DI)</label>
</div>

<div class="row"> 
  
  <!-- Modal Trigger -->
  <div class="input-field col s12">
    <button type="submit" id="somebutton" name="somebutton"  class="btn-floating btn-large red right modal-trigger" href="#modal1"  > <i class="mdi-content-send right"></i> </button>
    
    
  </div>
</div>

<!-- Modal Structure -->
<div id="modal1" class="modal">
  <div class="modal-content">
    <div class="col s12">
      <ul class="collection with-header">
        
        <div id='somediv' ></div>
        <div  class='inset'   >
          <div id="pai"; style="display: none;" class='message success'> </div>
        </div>
        
      </ul>
    </div>
  </div>
</div>