How does js send variables to php, or how does js trigger php functions? in page A. php, we need to count the clicks of each element (image link) on the page and store the clicks. Currently, php interacts with the database. Therefore, you are expected to update the corresponding table in the database after clicking (image link. How can I trigger the php response when I click (image link ~~ ------ Solution -------------- how does js pass variables to php, or how does js trigger php functions?
In page A. php, you need to count the clicks of each element (Image/link) on the page and store the clicks.
Currently, php interacts with the database, so you can update the corresponding table in the database after clicking (Image/link.
How can I trigger the php response when I click (Image/link ~~
------ Solution ----------------------
Use Ajax
------ Solution ----------------------
Use ajax or curl.
The fastest way is to use jquery's $. ajax method.
------ Solution ----------------------
// Give you a demo
// Download jquery. js files.
$. Ajax ({
Type: "POST", // request method
Url: "some. php", // request file
Data: "name = John & location = Boston", // transmission parameters
Success: function (msg ){
Alert ("Data Saved:" + msg); // returned result
}
});
// You can regard ajax as a form request. However, results can be returned in real time.