Hi there,
I'm quite new to roundcube, because a customer of mine needs a little function I had to programm for him. So I did with the current release of RC and it just works fine. But now there is a problem: My customer uses v1.0.3 and is not going to update within the next time and recommends to get the plugin compatible to this version. I had some trouble till now to find the issue but I'm noch able to do so.
It seems to be a problem with the output: my script waits for JSON-data but gets the hole page. Here a snippet of the relevant code:
$(document).ready(function() {
rcmail.addEventListener('plugin.myaction', myaction);
rcmail.http_post('plugin.myaction');
});
function myaction(response)
{
// do some stuff
}
This code-snipped is somewhat simple but should show what I want to do. The JS is only included if there is a defined condition so there will be no communication otherwise.
If the JS is loaded it sends a POST-request to the server to start the action which runs as expected, but there is no JSON-output as expected like in v1.1.3. I hope someone can help me out, I donÄt know where to look at and the changelogs doesn't help to find the relevant difference within v1.0.3 and 1.1.3...
class myplugin extends rcube_plugin
{
// [...]
public function init()
{
// register hook
$this->add_hook('myhook', array($this, 'mycheck'));
// register action
$this->register_action('plugin.myaction', array($this, 'myaction'));
}
public function myaction()
{
// send ajax-response back to client
$rcmail = rcmail::get_instance();
$rcmail->output->command('plugin.myaction', array('_mycontent' => 'content'));
}
public function mycheck($p)
{
// [...] do some stuff
if ($foo == $bar) {
// include js/css
$this->include_script('myplugin.js');
}
// return the object as expected by api
return $p;
}
}
Add $rcmail->output->send(); in myaction() method of the plugin class.
Hi!
I tried this out but it results in an error "501" - something with a missing template or so!?
Is there a possibility to get the documentation of this version anywhere?
[EDIT]
This is what I got after adding the $rcmail->output->send();:
SERVICE CURRENTLY NOT AVAILABLE!
Error No. [501]
[EDIT2]
Activating the debug_level "4" results in this:
SERVICE CURRENTLY NOT AVAILABLE!
Error loading template for
so there seems to be no name for the template (I guess there should be a "template for xyz"!?) which results in not being able to load a template??
Looks like it does not recognize the request as ajax request. Try rcmail.http_post('plugin.myaction', {});
Quote from: alec on October 20, 2015, 02:49:55 AM
Looks like it does not recognize the request as ajax request. Try rcmail.http_post('plugin.myaction', {});
You are my personal hero! Hours of troubleshooting and just three chars in a function-call are the solution!! Thank you very much!
For the mods: The problem is solved!