Execute CQ form actions with ajax

Avatar

Avatar

Krisgum

Avatar

Krisgum

Krisgum

15-10-2015

Hi All , 

 I have a custom form action nodes which has a forward.jsp via which the control is forwarded to my custom servlet . All this happens when the form start component is configured to execute the custom action . 

Now I want to achieve this behaviour  in ajax way  . In normal cases where I am not using cq form actions , I can add my js to a html and on submit execute a url to a servlet . With cq form actions how i can make a call to action's forward.jsp in ajax way ?

 

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Sham_HC

Total Posts

2.1K

Likes

158

Correct Reply

1.2K

Avatar

Sham_HC

Total Posts

2.1K

Likes

158

Correct Reply

1.2K
Sham_HC

15-10-2015

Answers (4)

Answers (4)

Avatar

Avatar

Krisgum

Avatar

Krisgum

Krisgum

15-10-2015

Hi Sham ,

 I'm infact trying to pull data via ajax , but I want to do it via cq form actions . I have some custom CQ form actions which actually pull data from external sources . I have my from start component which are configured to execute these actions on submit . 

Now I want to achieve the same behaviour of executing CQ form actions via ajax   , I just select the action in form start component and on submit the form should be submitted asynchronously . I have already achieved this by bypassing cq formactions and directly executing servlet by passing servlet path as url in ajax script .

 

regards

Avatar

Avatar

Sham_HC

Total Posts

2.1K

Likes

158

Correct Reply

1.2K

Avatar

Sham_HC

Total Posts

2.1K

Likes

158

Correct Reply

1.2K
Sham_HC

15-10-2015

I thaught you are looking to pull data into the page via AJAX.   If your request forward to servlet & from there make ajax request does not make sense because servlet is server side & why you want to make a ajax request there. Because ajax is client side.  Am i missing something here?

Avatar

Avatar

Krisgum

Avatar

Krisgum

Krisgum

15-10-2015

Hi ,

   Thanks for your replies . I can see how acs bundle ajaxes the components but i'm not sure how I can  make it fit to my requirement . As i had mentioned before and aas also mentioned in smacdonald post , i can directly call my servlet in ajax script and make it work  , but if i choose to use CQ form actions this approach wouldn't work . 

When using CQ form actions in formstart component , slingpostservlet is executed which redirects to formaction node and executes either forward.jsp or post.Post.jsp . I'm not able to figure out how acs commons base ajax component approach can be made fit here ? Any pointers ? 

 

Thanks in advance

 

 

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

15-10-2015

Here is a community article that talks about submitting data from a web page to an AEM Sling Servlet using AJAX:

http://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html