Use of jquery to pull records, but does not appear

Asked

Viewed 61 times

-2

I saw in a celke tutorial, select the BD using php and list the records using jquery. I can see you pulled the data, but when it comes to showing inside the span, it doesn’t. I wonder where I went wrong, and how I pull other records, because there are several checkboxes to filter and when you click on them I want you to give a select in the bank and bring me this information there and I can style it.

(To home php. is inside a folder, and the index in another folder(root folder), I don’t know if that’s why I don’t read, and I don’t know how to get inside the other folder, use netbeans)

HTML

<span id="conteudo"></span>

JQUERY

    <script>
        $(document).ready(function(){
            $.post('home.php', function(retorna)
                $("#conteudo").html(retorna);
        });

                });
    </script>

PHP

$consulta_bd = "SELECT * FROM uniao";  
  $result=pg_query($conexao, $consulta_bd);  
  if  (($result)){  
      while($linha_usuario = pg_fetch_assoc($result)){    
          echo $linha_usuario['cd_regua'] . "<br>";  
}  
    }   else      
{  
      echo "Nenhum resultado encontrado";  
}

1 answer

1


  $.ajax({
            url: "/home.php",  // coloque aqui o endereço que vai buscar os dados no banco         
            success: function (data) {                                  
                $('#conteudo').html(data); 
                $('#conteudo').show(); // Mostrar o retorno em texto no html

            },
            error: function (request, status, erro) {

                $('#conteudo').html('Ocorreu um erro, entre em contato com T.I!', erro);
                $('#conteudo').show();

            },
            complete: function (jqXHR, textStatus) {              

            }
        });
  • 1

    I did the first step, I used jquery to monitor the checkbox event, "When clicking on the 'regua' checkbox, consult the database and bring the 'regua' record that is there". Soon after monitoring if it is "checked", make the query in the BD and return me inside a flexbox. Whenever you mark the chexbox bring me that data. Can you tell me how I put inside jquery to bring me this query right after checkbox marking?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.