Ajax request on list items?

How i can fire ajax request on clicking each list item?
<?php
$i;

   for($i=1;$i<=$detail->stock;$i++) {?>

      <li class="dropdown-item" id="dexy"><a><?php echo $i; ?></a></li>

    <?php    }      ?>

Well, that’s rather vague.

Are you using a helper package like jQuery? Are you doing it in pure JavaScript? Are all the requests going to the same place? Do they need data attached?

using jquery, each list carries unique attribute

$('.dropdown-item').click(function () {
  $.ajax({
 //Do a thing. $(this) refers to the list item that was clicked on.
 });
}
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.