When you press one of the 300 buttons, the parameter should be transmitted by the Ajax.
Code:
$(document).on('click', '.lot-not-finished .lottery-member.empty, .lot-not-finished .take-part-btn', function() { var place = $(this).data('place'); ajax({thisPage: true, place: place}, function (data) { $('.user-balance').text(data.balance); $.notify(data.msg, "success"); FULL_LOT.myPlacesCount++; $('.myPlacesCount').text(FULL_LOT.myPlacesCount + n2w(FULL_LOT.myPlacesCount, SLOTS_TEXT)); MyLotsManager.add(FULL_LOT.info, 0); }, false); return false; });
The AJAX function itself:
function ajax(data, success, error) { var url = data.thisPage ? '' : '/ajax'; delete data.thisPage; $.ajax({ url: url, type: 'POST', dataType: 'json', data: data || {}, success: function (data) { if (data.status == 'success') { success && success(data) } else { if(data.msg) $.notify(data.msg, "error"); } }, error: function () { $.notify(LANG['ajaxError'], "error"); console.log(data); console.log(error); error && error() } }) }
I have already created a folder on the server / ajax and put index.php there and entered everybody into it .... Then I redirected the script to the ajax folder .. I canβt understand if my PHP file is receiving a value or not.
I already thrust there:
<?php echo $_POST['place'] $msg = 'chetko'; echo 'success'; $success = true; echo $msg; echo json_encode($msg); echo 'chetko'; $status = 'success'; echo json_encode($status); echo $status; echo json_decode($status); echo '111'; ?>
Who can explain to me what should be in my PHP file so that I still get this place value? Ajax it is sent - I see it in the console, when I press the button. But then nothing happens and I get an error.
I have been suffering for almost 2 hours, and I canβt understand if my PHP is accepting anything at all, and how to give Ayaks back the answer that he accepted .. :(
ΠΡΠΊΡΠΎΠΌ ΠΎΠ½ΠΎ ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΡΡΡ - Ρ Π²ΠΈΠΆΡ Π² ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Π΅Π³ΠΎ, ΠΏΡΠΈ Π½Π°ΠΆΠ°ΡΠΈΠΈ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡ.
screen request structure show. - Visman