LMSouq
php-dev Open

How to call a JavaScript function from PHP?

ZE
Zeeshan Rang
1 month ago
3 views
Problem Description
How to call a JavaScript function from PHP? <?php jsfunction(); // or echo(jsfunction()); // or // Anything else? The following code is from *xyz.html* (on a button click) it calls a `wait()` in an external *xyz.js*. This `wait()` calls wait.php. function wait() { xmlhttp=GetXmlHttpObject(); var url="wait.php"; \ xmlhttp.onreadystatechange=statechanged; xmlhttp.open("GET", url, true); xmlhttp.send(null); } function statechanged() { if(xmlhttp.readyState==4) { document.getElementById("txt").innerHTML=xmlhttp.responseText; } } and *wait.php* <?php echo "<script> loadxml(); </script>"; where `loadxml()` calls code from another PHP file the same way. The `loadxml()` is working fine otherwise, but it is not being called the way I want it.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base