Previously, the php code was redirected to a specific php page to execute the corresponding code. Can I bind a piece of code and a click event like a js Code, and then click it to execute this php code, do not need to jump to other pages? Previously, the php code was redirected to a specific php page to execute the corresponding code. Can I bind a piece of code and a click event like a js Code, and then click it to execute this php code, do not need to jump to other pages?
Reply content:
Previously, the php code was redirected to a specific php page to execute the corresponding code. Can I bind a piece of code and a click event like a js Code, and then click it to execute this php code, do not need to jump to other pages?
I want to click something, such as a button, and then execute a database operation to insert a row of records. Is it implemented using ajax?
Ajax is the most simple. I have done a similar simple demo a long time ago. You can take a look at it. The ajax encapsulated with Jq is very simple.
Ajax code: pass a value to php, receive the parameters returned by php, and enter them in html.
PHP processes database code and returns relevant content
The code is mounted on SAES. For local testing, you can modify conf. php or use the existing code mazuguang.sinaapp.com.
Hope to help you, Luck!
If you can solve your problem, you are welcome to adopt ~
If possible, output the clicked content to the page and hide it. Click it to display it. Otherwise, use ajax.
Php code has been executed when you render the page. You want to click it to execute 1. Write it as js call 2. ajax execute and return the result.