How to call a JavaScript function from PHP?

后端 未结 10 2363
误落风尘
误落风尘 2020-11-21 23:03

How to call a JavaScript function from PHP?

The followi

10条回答
  •  孤街浪徒
    2020-11-21 23:32

    Thats not possible. PHP is a Server side language and JavaScript client side and they don't really know a lot about each other. You would need a Server sided JavaScript Interpreter (like Aptanas Jaxer). Maybe what you actually want to do is to use an Ajax like Architecture (JavaScript function calls PHP script asynchronously and does something with the result).

    Click for Details
    
    function loadxml()
    {
        result = loadScriptWithAjax("/script.php?event=button_clicked");
        alert(result);
    }
    
    // script.php
    
    

提交回复
热议问题