Execute php function only when clicked (wordpress)

后端 未结 3 1755
自闭症患者
自闭症患者 2021-01-17 02:17

For one of my wordpress site php files, I have the following code:

  
Items
3条回答
  •  一生所求
    2021-01-17 02:38

    You can't really call a PHP function from javascript because by the time the browser sees the page, the PHP has already executed (or in your case, not executed )

    The only way for you to do what you want is to spin the PHP function off into a separate script and then call that file using AJAX. Have the script echo HTML, and then insert the HTML into the tab1 div in the AJAX callback.

提交回复
热议问题