Hello, this script works but not as it should, it puts the result for which I clicked into the console, and with each click a new script, and I want to be separated by a comma.
Help please implement
$(window).load(function() { //говорим скрипту что он сработает когда вся страница загрузится $('.btn.btn-primary.btn-lg.width').click(function(e) { //ловим клик $("#basket").show("slow"); // показываем как откроется форма var ID = $(this).data('id'); // берет элемент по которому кликнули $.ajax({ // сам ajax запрос url: "myscript.php", // обработчик на php data: { id: ID }, // данные которые передаются type: "POST", // метод }) .done(function(data) { //отладочный запрос по которому заносятся данные console.log(data); // выводим отладочную информацию }); }); }) 
data-id, i.e. It turns out you need at least two scripts: 1 - to adddata-idelements to the array when you click on an element, 2 - to send a request when you click on the compare button - Alex