[RCD] Plugin - AJAX GET request to cross domain

Jakob Bachhuber jakob-b at posteo.de
Mon Sep 12 11:21:25 CEST 2016


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();
}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.roundcube.net/pipermail/dev/attachments/20160912/b3d9db7f/attachment.sig>


More information about the dev mailing list