Update only div with ajax

Asked

Viewed 294 times

0

I have an ajax code that sorts items from my table, what I need is for it to refresh only in the div

ID Imagery Name Slug Order Situation Action

         <tbody>


         <?php
          foreach ($list as $row) {
           ?>

           <tr id="acomodacaoArray_<?=$row['id']?>">

            <td><?php echo $row['id']; ?></td>
              <td>
             <?php
             if($row['imagem']=='') {
              echo '<img src="../img/sem-imagem.jpg" width="50">';
               } else {
                 echo '<img src="../img/acomodacoes/'.$row['imagem'].'" width="50">';
                                  }
           ?>
            </td>
             <td><?php echo $row['nome_br']; ?></td>
              <td><?php echo $row['slug']; ?></td>
            <td><?php echo $row['ordem']; ?></td>
           <td>
            <?php
            if($row['situacao']=='Ativo') {
            echo '<span class="badge p-2 badge-success">ATIVO</span>';
             } else {
             echo '<span class="badge p-2 badge-danger">INATIVO</span>';
             }
              ?>
             </td>
              <td>

           <a href="acomodacao-editar.php?id=<?php echo $row['id']; ?>" class="btn btn-primary btn-sm"><i class="fe-edit-2"></i> Editar</a>
                                  <a href="#" class="btn btn-danger btn-sm" data-href="acomodacao-apagar.php?id=<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"><i class="mdi mdi-delete"></i>Apagar</a>
                                  </td>

                                  </tr>

                                  <?php
                                  }
                                  ?>              

                                  </tbody>
                                  </table>

 $(document).ready(function(){

        $(function() {
            $("table tbody").sortable({ opacity: 0.6, cursor: 'move', update: function() {
                var order = $(this).sortable("serialize");
                $.ajax({
                    url: 'ordem-acomodacoes.php?action=atualizaordem',
                    type: 'POST',
                    data: order,
                    success: function(data) {
            }
                });
            }
            });
        });

    });
  • Send the value of data for the div with $("seletor da div").html(data);.

  • Could you please put in the example above, I tried more did not work!

  • Do you want to change the content of the div with what comes from Ajax? The div has a id?

  • It already changes, what I want is to appear the change of the numbering without I need gives a refresh on the page

No answers

Browser other questions tagged

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