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
BedrockMission!

Learn More

View all

Sign in to view all badges

How to use JS method's in adaptive form page

Avatar

Avatar
Validate 1
Level 2
Jing_Luo
Level 2

Likes

2 likes

Total Posts

16 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
Jing_Luo
Level 2

Likes

2 likes

Total Posts

16 posts

Correct Reply

2 solutions
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
Jing_Luo
Level 2

15-10-2015

I am working on an adaptive form ,in this form there has a button to send an email. I followed this https://helpx.adobe.com/experience-manager/using/creating-custom-cq-email-services.html created custom CQ email services. It works. The adaptive form look likes:

Now I want to use the service when I click the button. I have write a function in a js file. How to use it.

function sendEmail(){
    //Get the email message data
    var server = $('#host').val() ;
 var from = $('#fromAddress').val() ;
    var to = $('#toAddress').val() ;
    var subject = $('#subject').val() ;
    var message = $('#message').val() ;

    var url = location.pathname.replace(".html", "/_jcr_content.email2.json") + "?to="+ to +"&from="+from +"&server="+server +"&subject="+subject +"&message="+message;

    $.ajax(url, {
        dataType: "text",
        success: function(rawData, status, xhr) {      
            try {
    $('#fromAddress').val('');
                $('#toAddress').val('');
                $('#subject').val('');
                $('#message').val('');
            } catch(err) {
                failure(err);
            }
        },
        error: function(xhr, status, err) {
            failure(err);
        }
    });
 }

Thanks,

Jing

View Entire Topic

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-10-2015

The above code is a form that posts data using AJAX. 

To work with an AEM 6 Adaptive Form - see this article:

https://helpx.adobe.com/experience-manager/using/posting-aem-6-form-data.html

You can build the Adaptive form in AEM and learn how to post its data to an AEM service.