Microsoft has provided one service called Power Automate where you can create flows for automation.
You can achieve your requirement with below steps:
Create a flow with "When a HTTP request is received" trigger so you can call your flow from AJAX request.
In flow, using SQL server action, you can add data in SQL table.
Write button click event in your ...