Hi Team,
I have created simple form it contains 4 fields like
First Name
Last Name
DOB
Gender
After submitting i need to call servlet to send this to some other system.
How i can send these data to my custom servlet
I have created my path based servlet and path is /bin/aem/customerdata
Can some one help me here
Views
Replies
Total Likes
You can post the data to the sling servlet's doPost method using the JQuery AJAX request.
$.ajax({ type: 'POST', url:'/bin/myServlet', data:{'First Name' : val1,'Last Name' : val2}, //passing values to servlet success: function(msg){ //Success logic } });
Hope this helps!
Thanks for your reply.
I am using the adaptive form which contains 4 fields
First Name
Last Name
DOB
Gender
Can i use same $ajax call in Adaptive form as well.
if yes where i need to write that ajax call code is
You can edit the servlet call sample shared previously to include 4 parameters.
This AJAX call should be invoked as part of the submit action rules of the adaptive form. You can read more about rule editor here[0]
Hi,
as per your suggestion i am written code like below is it correct way to write
@manikanthar1295 Yes, that's how a sling servlet is called.
You need to make sure that the servlet is registered and that the data parsed from the AF is the expected one for the servlet to process further.
Step 1: Test your servlet via postman.
Step 2: If it works via postman then make an AJAX call from the script editor to the servlet.