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

113
Vistas
Jquery function not working properly with php loop

I am working with jQuery and PHP. I am using AJAX in the controller and I am getting "Feeds" (Posts) in a PHP loop.

The issue is that whenever I click on any button in that loop it shows me the alert multiple times instead of one time. How can I solve this?

Right now I just alert a simple message for the test but the alert box shows more than 1 time after a single click. I just want that it should alert only one time so I can write/execute my function further.

Thank you in advance.

<?php
  function fetch()
  {
    $FeedId;
    (dynamic) $FeedData = $this
      ->M_main
      ->GetFeedData(); // getting feed data from database

    foreach ($FeedData as $feeds)
    {
      if ($feeds['flag'] == "feed")
      {
        $GetFeedComments = $this
          ->M_main
          ->GetFeedsComment($FeedId);

        $TotalFeedsComments = $GetFeedComments['TotalRows'];
        if ($TotalFeedsComments > 1)
        {
          $Loads = '<div class="show_more_main" id="show_more_main' . $postID . '">
                      <input type="hidden" name="fixs" value="' . $postID . '" id="fixs">
                      <input type="hidden" name="MinValue" value="' . $postID . '" id="MinValue">
                      <input type="hidden" name="MaxValue" value="' . $postID . '" id="MaxValue">
                      <span id=' . $postID . ' data-val=' . $postID . ' data-status=' . $postID . ' class="show_more" title="Load more posts">Show more</span>
                      <span class="loding" style="display: none;"><span class="loding_txt">Loading...</span></span>
                    </div>';
        }
        else
        {  
          $Loads = "";
        }
      }
    }

    $paths = base_url() . "Main/AddComments";
    echo "<script>
      $('.show_more').click(function (e) {
        e.preventDefault(); 
        alert("Helloworld"); 
      });
    </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