Paging without refresh receive no value

Asked

Viewed 180 times

0

I have three files:

1) listarusuarios.php Search the database to list

2) paginação. who pages the archive

3) dash.js where do I list the files without updating the page

1) listarusuario.php send the link to the pagination and some values

 $paginacao = new \App\adms\Models\helper\AdmsPaginacao(URLADM . 'usuarios/listar' , **'usuarios'**); 

2) paginação.php receives the link and the second users value

function __construct($Link, **$Var = null**){
    $this->Link = $Link;
    $this->Var = $Var;
}

$this->Resultado .= '<li class="page-item"><a class="page-link" href="#" onclick="listar('.$iPag.', **'.$this->Var.'**)">'.$iPag.'</a></li>'; 

on this line above that sends the values to the js file

3) dash.php receives the values

$(document).ready(function () {
   var varcomp = "";
   var pagina = 1; //página inicial
   listar(pagina, varcomp); 
}); 

function listar(pagina, varcomp) { 
    var dados = {
    pagina: pagina
    varcomp: varcomp //quando coloca o varcomp a paginçao não funciona
};


   $.post('../../adm/**usuários**/listar/' + pagina + '?tiporesult=1', function (retorna) { // eu quero que seja dinâmico para na parte aonde esta o usuários, entre outros valores ex: paginas
      $("#conteudo").html(retorna);

   });
} 

have already done console.log(varcomp) but the users of as >> 'users' is not defined <<

  • Kayo, you can do what you want with the chosen technologies yes, probably someone will answer you there with the tips, but why not use a simple two-way databinding framework like Angularjs or Vuejs? Another thing, I suggest implementing API standards that in the case of pagination would be. get and not .post. The more canonical your project, the better for maintenance and for people to help.

  • Missing a comma between pagina: pagina and varcomp: varcomp.

  • in the case then I already put the comma, qdo I typed here I ski, but still not right

  • I was able to make it dynamic;

1 answer

0


I was able to make it dynamic, I don’t know if it was the right way

$(document).ready(function () {
  var pagina = 1; //página inicial          
  listar(pagina);
});

function listar(pagina) {
    var link = window.location.pathname;
    link = link.replace("/projeto1/", "");
    var niv = link.split("&")[1];
    link = link.split("&")[0];

    var dados = {
        pagina: pagina
    };

$.post('../../' + link + '/' + pagina + '&' + niv + '&tiporesult=1', dados, function (retorna) {
    $("#conteudo").html(retorna);
});

}

Browser other questions tagged

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