Expand my Community achievements bar.

SOLVED

Execute CQ form actions with ajax

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Level 10
5 Replies

Avatar

Correct answer by
Level 10

Avatar

Level 10

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

Avatar

Level 4

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

Level 10

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

Level 4

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