Skip to content
Advertisement

Call php function with onclick event?

I want to delete project from database.Before deleting I want to confirm it whether user want to delete or not.If user click on okay it has to call delete function.But in the code when user click the function is get called not only user click on okay but also click on concel.For other alter statement it is working fine.For calling php function only it gives problem.

How can I solve this?

code is,

JavaScript

Advertisement

Answer

Just follow this code to achieve using jQuery ajax call. This is the HTML code with jQuery included and I’ve used test.php file in the same directory. Just write your PHP function in test.php file. Finally the response will be displayed in the given div after the user pressed confirm.

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