Trigger PHP function by clicking HTML link

后端 未结 5 1346
耶瑟儿~
耶瑟儿~ 2020-12-21 03:04

Is it possible to trigger a PHP function by just clicking a link? Or should I stick with the form submit method? If clicking the link will work, where should the link refer

5条回答
  •  自闭症患者
    2020-12-21 03:26

    You can do this by means of loading the entire page over again by the use of form submission, or by loading specific page contents directly into the page without needing to go from page to page. The second method is called "AJAX" (Asynchoronous Javascript and XML). Here are two examples, one of each specified.

    Form submission approach

    form.php

    
    ...
    

    AJAX approach

    ajax_file.php

    
    

    form.html

    
    
    
    
    
    click to call function
    
    
    

提交回复
热议问题