Roundcube Community Forum
Third Party Contributions => API Based Plugins => Topic started by: iBem on June 15, 2021, 06:46:33 PM
-
Hi
I am trying to call my php function from javascript file.
This is what I have
php file:
function init()
{
$this->include_script('client.js');
$this->register_action('plugin.test', array($this, 'test'));
}
function test($args)
{
echo("<script>console.log('PHP: " . "js is working" . "');</script>");
}
js file:
rcmail.http_post('plugin.test');
When I run this I get an error:
jquery.min.js?s=1612812585:36
POST http://localhost/roundcube/?_task=mail&_action=plugin.test 500
(Internal Server Error)
How should this be done correctly and could I also call javascript function from php file ?
-
The problem is your PHP is invalid, echo isn't a function https://www.php.net/manual/en/function.echo.php
-
The problem is your PHP is invalid, echo isn't a function https://www.php.net/manual/en/function.echo.php
But if I call my test function inside my php file the echo will print text to console. And I get the POST error even if the test function is empty.
-
Did you post the full plugin PHP file? What is in the Roundcube error log?