Tell me, please, on the question - my main code is executed on php, I want to make a check on the buttons. On php, I will do the check itself, but I would like it to be with a pop-up window.

Here is an example of banal deletion of records from a table.

if(isset($_POST['argys']) and (!empty($_POST['abs']))) { $Yabs=$_POST['abs']; $result=$dbh->prepare("DELETE FROM `Oke`.`tovars` WHERE `tovars`.`id` = :id;"); foreach ($Yabs as $id) { $result->execute(array(':id' => $id)); } } 

The code is 100% working, the only thing is tell me how to check the link with JS.

  • You send a request to the north, where your script is executed, the script returns the result, successfully or not, in response to the request you catch, successfully or not, and you deduce what you need - Vasily Barbashev

1 answer 1

You need AJAX. When you click on a button, for example, initialize the ajax request, somewhere at this moment you pop-up pops up - output the result in the block you need.

 $( "form" ).submit(function() { //измените на нужное вам событие $.ajax({ type: 'POST', url: 'путь до вашего обработчика php', data: { x: $('#input1').val(), y: $('.input2').val() }, success: function(data) { $('#result').html(data); } });}) 

And on the side of the php script, you simply give the result through echo. You can add styles.