Skip to content
Advertisement

Delete SQL values without page reload (AJAX, PHP)

I have a PHP file which shows the entries of a specific id within a SQL table. Now i want to be able to delete entries and show the updated table without a page reload.

Iam trying my best with a solution via AJAX, but no matter which entry i choose to delete, everytime only the one at the top gets deleted.

I hope someone has clue why this happens.

Here is my show.php:

JavaScript

This is my del.php:

JavaScript

The show.php is included in a another file, where it gets the variables like $transitnr.

Advertisement

Answer

You cannot use same id for mutliple elements instead use class then you can use .closest() and .find() method to get required input values and then send same to your backend.

Demo Code :

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement