Problem loading jquery load [closed]

0

I'm having trouble loading these values into the jquery load.

Follow the code.

Javascript:

 $('.buscando').click(function(){

            var id = document.getElementById('campo1').value;

            $("#cliente1").load('/wbahd/servico_servlet?acao=buscar&busca='+id);
          });

This code makes the action take the parameter but does not load the page.

HTML:

 <div class="form-group">
        <label for="busca">Nome Servico*:</label> <input id="campo1" type="text" class="form-control" placeholder="Insira um nome para busca">
    </div>
    <a href="#"  class="btn btn-default btn-cadastrar-btn buscando">Buscar</a>

    </div>

Obg

    
asked by anonymous 19.05.2017 / 03:46

1 answer

2

The load () method has two other optional parameters that we can use, if necessary, that are specified with typical jQuery properties and values.

For example: {acao: "buscar", busca: id} with this code would be sending the page action and search with the values "search" and id , where id is the variable with value passed through the input. This data travels in the URL by the "POST" method.

Script

$(document).ready(function(){
    $(".buscando").click(function(evento){
        evento.preventDefault();
        var id = $('#campo1').val();
        $(".cliente1").load("/wbahd/servico_servlet", {acao: "buscar", busca: id}, function(){
        });
    });
})

HTML

<div class="cliente1"></div>
<div class="form-group">
    <label for="busca">Nome Servico*:</label> <input id="campo1" type="text" class="form-control" placeholder="Insira um nome para busca">
    <a href="javascript:void(0)" class="btn btn-default btn-cadastrar-btn buscando">Buscar</a>
</div>
    
19.05.2017 / 14:15