By clicking on the link the ID value to pass to the server with AJAX POST method?

index.php

<a class="image" href="<?= $img['path_original_image']?>" target="_blank" id="<?= $img['count_opened']?>"> //give the number of opening pictures
 <img src="<?= $img['path_min_image'] ?>" alt="#"></a>
<p id="cart-count">()</p>

<script src="jquery.js"></script>
the <script>
 $(document).ready(function () {
 $(".image").click(function () {
 var params = {
 count: $("#id").val(),
}

 $.post("photo.php", params, function (data) {
$("#cart-count").html(data);
});
});
});
</script>


photo.php

<?php
$count = $_POST['params'];
echo $count; //nothing displays
March 12th 20 at 08:11
0 answer

Find more questions by tags PHPAJAX