Run PHP function on html button click

前端 未结 6 1036
渐次进展
渐次进展 2021-01-31 00:43

I need to run some PHP function when a button is clicked. I know this is not supposed to be php\'s use, rather js should do it, but what my functions are doing in gathering data

6条回答
  •  既然无缘
    2021-01-31 01:27

    It depends on what function you want to run. If you need something done on server side, like querying a database or setting something in the session or anything that can not be done on client side, you need AJAX, else you can do it on client-side with JavaScript. Don't make the server work when you can do what you need to do on client side.

    jQuery provides an easy way to do ajax : http://api.jquery.com/jQuery.ajax/

提交回复
热议问题