Submit Ajax query on another page

Asked

Viewed 108 times

0

Good morning. I’m making a shared racing web app, like "Uber". I want you to submit a query to the database with the list of registered drivers searching for Cpf, but I want you to show in this green carousel.

inserir a descrição da imagem aqui

In this code with Ajax, it performs perfectly, even put a div down to test and works perfectly.

<div id="motorista" style="height: 380px;">
<div class="row" style="margin-bottom: 0;">
    <div class="input-field col s10 ">
        <input placeholder="Busca por CPF" id="cpf" type="text" class="validate">
    </div>
    <div class="input-field col s2 ">
        <button class="btn-floating btn-large waves-effect waves-light " type="submit" id="buscar"><i class="material-icons">search</i></button>
    </div>

    <script>

        function buscar (cpf){
            $.ajax({
                type: 'POST',
                dataType: 'html',
                url: 'componentes/cons_motoca.php',
                beforeSend: function(){
                    $("#cons_motoca").html("Segura as pontas");
                },
                data: {cpf: cpf},
                success: function (msg){    
                    $("#cons_motoca").html(msg);
                }
            })
        }

        $('#buscar').click(function(){
            buscar($("#cpf").val());
        });

    </script>
</div>

// resto de código

</div>

<div id="cons_motoca"></div>

But I need you to present in this external code, which is the carousel:

<div class="carousel carousel-slider center" data-indicators="true" style="height: 480px;">
<div class="carousel-fixed-item center">
<a class="btn waves-effect white teal-text darken-text-2">Excluir</a>
</div>
<div class="carousel-item teal white-text" href="#one!">
<h2>Lista de Corridas</h2>
<p class="white-text"><div id="cons_motoca"><?php include("componentes/cons_motoca.php"); ?></div></p>
</div>
<div class="carousel-item teal lighten-1 white-text" href="#two!">
<h2>Lista de Motoristas</h2>
<p class="white-text">Aqui apresentará uma lista dos Motoristas cadastrados</p>
</div>
<div class="carousel-item teal lighten-2 white-text" href="#three!">
<h2>Lista de Passageiros</h2>
<p class="white-text">Aqui apresentará uma lista dos Passageiros cadastrados</p>
</div>
</div>
  • I didn’t understand the question right, you already managed to set up the consultation but you can’t feed the Carousel?

  • yes, the consultation is already mounted, perfect, but I can not present at the carousel...

  • The code seems correct, which is not working?

  • yes, the code is correct, but I do not know how to present the list of drivers on the carousel... I know it must be something very simple, but since I am a beginner, I can not find out...

  • When you make the query nothing appears in the div?

  • I believe I must have to touch something in the Ajax script...

  • then it appears in the div that is on the page itself, but I need it to present in a div that is on another page

  • What does the other page have to do with the page that is calling ajax? is a daughter page?

  • If the other page was opened from the Ajax page, it is possible to do this, but if it is not, there is no pq they have no link.

  • The first page is where you have the Cpf query fields to find the drivers and the ajax script. The second is where the carousel is, which is where I want the list of drivers to appear.

  • As I said, it is impossible to play the result of an Ajax on another page, EXCEPT if the two have a link, ie if one was opened by the other.

Show 6 more comments
No answers

Browser other questions tagged

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