How to pass response data from internal/external servlet to successful/error event of form submission validation?

Avatar

Avatar

yuvraj1610

Avatar

yuvraj1610

yuvraj1610

13-09-2020

Hi All,

 

I am using ootb form submit action - 'Submit to Rest Endpoint'.

 

  • I am able to hit my post servlet using this submit action.
  • My servlet is returning a response data for eg : "data". It can be any data json or string.
  • On the adaptive form container, I have selected "Use Asynchronous Submission
  • I am using "Form Submission" event on the rule editor of form container.

 

How can I get the response data in my front end javascript which I am writing in rule editor of a form submission event or if not in rule editor what is the best way to get the response data?

 

I know I can write the rule on click event of the submit button and directly hit my servlet and get the response but I want to use Submit action(post.Post.jsp) to achieve it. Is there any way?

 

View Entire Topic

Avatar

Avatar

Mayank_Gandhi

Employee

Avatar

Mayank_Gandhi

Employee

Mayank_Gandhi
Employee

14-09-2020

@yuvraj1610  You can make AJAX call to your post servlet in AEM forms rule editor. Just take care of CORS

 

https://api.jquery.com/jquery.post/

 

http://www.aemcq5tutorials.com/tutorials/aem-forms/implement-autocomplete-adaptive-form/