I am new to javascript wo开发者_运维知识库rld.
I wrote a function in PHP. How do I call it when I click a button or image in html?
If you want to call serverside functions you should use AJAX.
Goto http://www.w3schools.com, and take the AJAX tutorials.
You have a general missunderstanding.
PHP is serverside, HTML/JS is clientside.
so if you want to call a server method from clientside you have to execute a request to the server. in modern days this is done via an AJAX request.
Checkout Jquery ajax functions this would be the easiest way.
You can't. You have to make a request to a PHP page, usually via AJAX, and then that page has to call the PHP function and return the results.
精彩评论