There is such a php code
<?php $data = parse_ini_file("likes.ini"); // Парсим INI-файл for($id=1; $id<4;$id++){ $likes = $data[$id]; // Получаем количество лайков у статьи ?> <div id="like" data-id="<?=$id?>"> <?=$likes?> </div> <?php }?> and js
<script type="text/javascript"> $(document).ready(function () { $("#like").bind("click", function (event) { /*if (get_cookie("VoiceLook") != "Yes") {*/ $.ajax({ url: "like.php", type: "POST", data: ("id=" + $("#like").attr("data-id")), dataType: "text", success: function (result) { if (result) { $("#like").text(Number($("#like").text()) + 1); } else alert("Error"); } }); /*document.cookie = "VoiceLook=Yes"; } else{ alert("Вы уже голосовали!"); }*/ }); }); function get_cookie(cookie_name) { var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); if (results) return (unescape(results[2])); else return null; } </script> That is, the page displays several divs with the same id when you click on which the number should increase by +1. (this is a likes system with writing to a file via like.php). But it turns out that the file like.php all the time is passed only id = 1 (first diva) and it turns out that you can only increase by 1 div. How can I fix this?
As I understand the problem in js, it cannot correctly understand which id I click in connection with which it constantly sends id = 1.