How asynchronous submission works
AEM Forms provides out-of-the-box success and error handlers for form submissions. Handlers are client-side functions that execute based on the server response. When a form is submitted, the data is transmitted to the server for validation, which returns a response to the client with information about the success or error event for the submission. The information is passed as parameters to the relevant handler to execute the function.
In addition, form authors and developers can write rules at form level to override default handlers. For more information, see Override default handlers using rules.
Let us first review the server response for success and error events.
Server response for submission success event
The structure for the server response for submission success event is as follows:
{
contentType : "<xmlschema or jsonschema>",
data : "<dataXML or dataJson>" ,
thankYouOption : <page/message>,
thankYouContent : "<thank you page url/thank you message>"
}
The server response in case of successful form submission includes:
- Form data format type: XML or JSON
- Form data in XML or JSON format
- Selected option to redirect to a page or display a message as configured in the form
- Page URL or message content as configured in the form
The success handler reads the server response and accordingly redirects to the configured page URL or displays a message.