[horde] Question about Ajax.Request

Ralf Lang lang at b1-systems.de
Tue Apr 10 06:39:17 UTC 2018


Am 09.04.2018 um 21:32 schrieb Mike Poznecki:
>
> I need to pass an array and a string to my php page. But I cannot figure out how to do this. Here is my code:
> Javascript: (myVar is an array.)
> function processData(myVar){  new Ajax.Request('myPage.php', {    type: 'post',    data: {myCmd: 'ProcessIt', addData: myVar},  onSuccess: function(transport) {    return transport.responseText;  }  });}
> PHP:
> <?phpif (empty($_POST)){ // $_POST is always empty.  Even though the type is array.}
>
>
> As my comment says, $_POST is always empty. I have tried many ways to get some values out of it, but it is just empty.
> Can someone show me what I am doing wrong?
>
>
>
>
Hi Mike, if you want data from Horde, best do it this way:

Call HordeCore.doAction() from the client. doAction adds
security/authentication related stuff to your bare ajax call.

It will call $app/lib/Ajax/Application/ and, implicitly, a Handler. The
handler needs to have a method name corresponding to the command used in
doAction. Return an array/hash of serializable data and doAction will
receive a JSON structure including this data.

I think there is a horde wiki entry explaining this ajax mechanism in
detail.


More information about the horde mailing list