Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

how to call servlet from listener event JS function?

Avatar

Level 3

I have two field in dialog  - Pathfield /  HTML5SmartImageField .

From Pathfield, i will select one page which would be having one image.

Now what i want is - once i select page from pathfield , that image will automatically rendered on my smartimagefield.

I used dialogclose listener to listen the pathfield, once the page got selected my dialogclose event listener JS would be called.

In that JS, i want to make call ajax to call servlet.

From that ajax, i would pass path of the page selected from pathfield to the servlet. In that servlet, i would manipulate that path and will get that image path from its JCR property.and then plan to return back to ajax on success.

But I dont know can i make ajax call from Listener JS?

If possible , please provide me some reference for this in which we are calling servlet in listener JS 

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

Please have a look at these helpx article:

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

    // Submitting Adobe Experience Manager form data to Java Sling Servlets

    Here we are cresting a custom sling servlet, that we will be calling from jquery AJAX call.

 $.ajax({
type: 'POST', 
url:'/bin/mySearchServlet',
data:'id='+ claimId+'&firstName='+ myFirst+'&lastName='+ myLast+'&address='+ address+'&cat='+ cat+'&state='+ state+'&details='+ details+'&date='+ date+'&city='+ city,
success: function(msg){
 
        var msgId= json.id;
        var lastName = json.lastname;
        var firstName = json.firstname;
 
        $('#ClaimNum').val(msgId);
        $('#json').val("Filed by " + firstName + " " + lastName);
              });
        });

Here we are submitting the data, but we can also return the data as well.

I hope this would help you.

~kautuk

View solution in original post

2 Replies

Avatar

Correct answer by
Administrator

Hi 

Please have a look at these helpx article:

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

    // Submitting Adobe Experience Manager form data to Java Sling Servlets

    Here we are cresting a custom sling servlet, that we will be calling from jquery AJAX call.

 $.ajax({
type: 'POST', 
url:'/bin/mySearchServlet',
data:'id='+ claimId+'&firstName='+ myFirst+'&lastName='+ myLast+'&address='+ address+'&cat='+ cat+'&state='+ state+'&details='+ details+'&date='+ date+'&city='+ city,
success: function(msg){
 
        var msgId= json.id;
        var lastName = json.lastname;
        var firstName = json.firstname;
 
        $('#ClaimNum').val(msgId);
        $('#json').val("Filed by " + firstName + " " + lastName);
              });
        });

Here we are submitting the data, but we can also return the data as well.

I hope this would help you.

~kautuk