Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Lite 7

 AfterLogic Forum : AfterLogic WebMail Lite 7
Subject Topic: How to Send PlugIn Data via Ajax Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
iSofia
Newbie
Newbie
Avatar

Joined: 24 May 2014
Location: Singapore
Online Status: Offline
Posts: 35
Posted: 16 October 2014 at 8:16am | IP Logged Quote iSofia

The AJAX plugin example clearly demonstrates how to receive data via AJAX:

Code:
AfterLogicApi.sendAjaxRequest({'Action': 'GetData'}, function (oData)...

How would we go about sending data through this AJAX method?

Thank you.
Back to Top View iSofia's Profile Search for other posts by iSofia
 
iSofia
Newbie
Newbie
Avatar

Joined: 24 May 2014
Location: Singapore
Online Status: Offline
Posts: 35
Posted: 16 October 2014 at 11:59pm | IP Logged Quote iSofia

I found this in the manual, and it seems like just the ticket, but I don't know how to use it.

JavaScript API (WebMail):
-> Client-side API Hooks
--> AfterLogicApi.addPluginHook function (ajax-default-request)


I'm assuming that the syntax might be something like this:

Code:
AfterLogicApi.addPluginHook(
{
     'ajax-default-request', 'my additional data'
});


But how would the data be received by the class in index.php?

Please help. Thank you.
Back to Top View iSofia's Profile Search for other posts by iSofia
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 17 October 2014 at 2:57am | IP Logged Quote Igor

AfterLogicApi.sendAjaxRequest() function can accept arbitrary number of parameters submitted as follows:

Code:
oParameters = {
'Action': 'ActionValue',
'Parameter1': 'Parameter1Value,
...
}


Action parameter is the only one mandatory there.

As for adding ajax-default-request hook, it's done as follows:

Code:
   AfterLogicApi.addPluginHook('ajax-default-request', function (sAction, oParameters) {

// this code will be run every time any AJAX request is going through

   });


Hope this helps!

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
iSofia
Newbie
Newbie
Avatar

Joined: 24 May 2014
Location: Singapore
Online Status: Offline
Posts: 35
Posted: 17 October 2014 at 3:16am | IP Logged Quote iSofia

Hi Igor. Thank you so much for your answer. Hope you're still there!

Once the parameters are passed to the class in index.php, how does the function read it?

Please help.

Back to Top View iSofia's Profile Search for other posts by iSofia
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 17 October 2014 at 3:37am | IP Logged Quote Igor

You can obtain parameter value by its name as follows:

Code:
$this->oPluginManager->Actions()->getParamValue('parameter_name_here', 'default_value_here');


For example, if you're sending information about user's gender, that would be something like this on server side:

Code:
$sUserGender = $this->oPluginManager->Actions()->getParamValue('user_gender', '');


Hope this makes sense ;)

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
iSofia
Newbie
Newbie
Avatar

Joined: 24 May 2014
Location: Singapore
Online Status: Offline
Posts: 35
Posted: 17 October 2014 at 3:51am | IP Logged Quote iSofia

Igor wrote:
You can obtain parameter value by its name as follows:

Code:
$this->oPluginManager->Actions()->getParamValue('parameter_name_here', 'default_value_here');


For example, if you're sending information about user's gender, that would be something like this on server side:

Code:
$sUserGender = $this->oPluginManager->Actions()->getParamValue('user_gender', '');


Hope this makes sense ;)

It makes perfect sense, although it's not something that I would have figured out myself; EVER.

I don't believe that this is documented, and I'm sure that it would prove to be very helpful to many.

I sincerely thank you, Igor. You've made my day, and my weekend!

Just my tears of joy!
Back to Top View iSofia's Profile Search for other posts by iSofia
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 17 October 2014 at 4:00am | IP Logged Quote Igor

Good point, thank you. I'll make sure our docs team will take care of that, and maybe there will be a separate sample plugin demonstrating use of custom parameters.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
iSofia
Newbie
Newbie
Avatar

Joined: 24 May 2014
Location: Singapore
Online Status: Offline
Posts: 35
Posted: 17 October 2014 at 4:03am | IP Logged Quote iSofia

Igor wrote:
Good point, thank you. I'll make sure our docs team will take care of that, and maybe there will be a separate sample plugin demonstrating use of custom parameters.

That sounds great! Thanks again.
Back to Top View iSofia's Profile Search for other posts by iSofia
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide