I just started learning PHP and was wondering if there is a way to trigger a portion (a function really) of a php script when a user clicks on a link/button without redirecting the user to a new php script page?.
Basically, is there a way to invoke php functions through client side user actions like you have in javascript?.
Here’s how you can do it with JQuery using
$.ajax()[Docs]Most MVC frameworks – one example being CodeIgniter allow you to execute specific functions in the controller via the URL:
http://domain.com/mycontroller/myfunc. If your function takes two arguments, for example:You can access it via
http://domain.com/mycontroller/foobar/abc/123making your ajax calls super easy.