Hey all,
I am developing a plugin, where I wanna ask my personal web API about some email details. First, I tried to make a jquery ajax request. Firebug shows me the correct response, but I always get a 404 error. So the plugin does not get the result. I can imagine that is because a cross domain issue.
Then I tried to do an ajax request to my server side plugin code, where I would try to make a php request to my API. But to be honest, I can't figure out how to send my values with such a GET request, process them within the php function and send it back.
Of course, I have read the documentation. I also analysed some other plugins, but it is still just random guessing for me.
Thanks for any help.
Cheers, Jack
In my JavaScript I do: var value = "test" rcmail.http_get("plugin.someaction","value"+value);
In my php I do: $this->register_action('plugin.someaction', array($this, 'actions'));
and
function actions($args) { echo '<script type="text/javascript">alert("' . $args . '")</script>'; echo '<script type="text/javascript">alert("' . $args['value'] . '")</script>'; $this->rc->ouput->send(); }
On Mon, Sep 12, 2016 at 11:21 AM, Jakob Bachhuber jakob-b@posteo.de wrote:
[...]
Of course, I have read the documentation. I also analysed some other plugins, but it is still just random guessing for me.
The relevant part for you is probably here: https://github.com/roundcube/roundcubemail/wiki/Plugin-API#ajax-requests-and...
In my php I do: $this->register_action('plugin.someaction', array($this, 'actions'));
and
function actions($args) { echo '<script type="text/javascript">alert("' . $args . '")</script>'; echo '<script type="text/javascript">alert("' . $args['value'] . '")</script>'; $this->rc->ouput->send(); }
The way to pass data back to the client is not using echo
but send
it a "command" for which your plugin has already registered an event
listener:
$rcmail->output->command('plugin.somecallback', $args);
Makes sense?
~Thomas