How can I run PHP code on click of a link? (<a>link here</a>
)?
I know how listen for a click in JavaScript or JQuery And then perform JavaScript or JQuery, but how would I do PHP?
How can I run PHP code on click of a link? (<a>link here</a>
)?
I know how listen for a click in JavaScript or JQuery And then perform JavaScript or JQuery, but how would I do PHP?
PHP code is a server side code while JavaScript is a client side. Thus PHP code executes on the server while JS code executes in client's browser. There are no way to execute PHP code in client's browser but what you've probably needs is AJAX.
AJAX requests can be called from client's browser to run some custom server side code which will return the result to browser. The way to do it from jQuery is using $.ajax() method or one of it variants - $.post() and $.get().