title: Ajax Call In Each Loop
body: <p>I create dynamic html buttons <br>
  I want for each button, when i press one of them, then create a ajax call to take value. But my problem is, that I get as many consoles as their number of buttons..<br></p>
  <p><strong>My php code is:</strong></p>
  <pre><code>if(isset($_POST['disable_appointment'])) {
  
      $query = &quot;SELECT * FROM appointments&quot;;
      $result = mysqli_query($db, $query);
  
      $return_arr = array();
  
      while($row = mysqli_fetch_array($result)){
  
          $appointment_date = $row['appointment_date'];
          $appointment_time = $row['appointment_time'];
  
          $return_arr[] = array(&quot;appointment_time&quot;=&gt; $appointment_time);
      }
  
      exit(json_encode($return_arr));
  
  }
  </code></pre>
  <p><strong>My JQuery code is:</strong></p>
  <pre><code>$( &quot;.appointment_button&quot; ).each(function(index) {
      $.ajax({
          url:'../../groomer/groomer_server.php',
          type: 'post',
          dataType: 'JSON',
          data:{
              disable_appointment:1
          },
          success: function(response){
              console.log(response);
          }
      });
  });
  </code></pre>