Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
How topass AJAX variables to another JS function

Hi everyone I am currently developing a catalog and I manage user comments on products which works well, but I have now decided to use AJAX to do it but unfortunately I am new to AJAX and it creates a bit of trouble for me for the moment. I would like to pass the 'id' and 'pageNumber' variables to the getReviews () function so that it can use them in the url

HTML

<body>
<ul>
    <li><a class='page-link is-active' data-id=".$prodId." data-link=".$counter.">$counter</a></li>";
    <li><a class='page-link' href='$ver=$counter' data-id=".$prodId." data-link=".$counter.">$counter</a></li>";
</ul>
 
<div id='display_reviews' class="col-md-7"></div>
</body>

AJAX

<script>
    $(document).ready(function(){
getReviews();
 
$(document).on('click', '.paging li a', function(e){
        e.preventDefault();
        var id = $(this).data('id');
        var pageNumber = $(this).data('link');
        $.ajax({
            type: 'GET',
            url: '/mysite/product/?action=getProductReviews&id='+id+'&page='+pageNumber,
            dataType: 'json',
            success: function(response){
                getReviews();
            }
        });
    });
 
function getReviews(){
                $.ajax({
            type: 'GET',
            url: '/mysite/product/?action=getProductReviews&id='+id+'&page='+pageNumber,
            dataType: 'json',
            success: function(response){
                    $('#display_reviews').html(response);
            }
        });
};
    });
</script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda