Runtime tools : Channels components : AJAX channel : Tasks : Using the JSON formatter for AJAX requests
  
Using the JSON formatter for AJAX requests
This section describes how to use a JSON formatter for AJAX requests in a UNICOM® Digital Transformation Toolkit (UDTT™) application.
The response data for an AJAX request is retrieved from the context that contains the execution result of the request, and then the format of the data is converted for the response. Data for the response can be converted by using two different methods: the default data conversion method in UDTT HTML channel and by using the UDTT JSON formatter.
The channel default way is to transform all the data in the operation context into a JSON string as shown in the example below. All the data elements in the userKColl are converted into the JSON string on the right. This method of data transformation is used by the UDTT enhanced HTML channel.
Transforming data from a UDTT context to a JSON string
This graphic is described in the surrounding text.
However, converting all the data elements in a context, including data elements that are not required for a response, might cause overhead on a network, and the conversion of the unnecessary data might have unwanted effects on the browser side. A JSON formatter converts only the data that is required for response to an AJAX request. The JSON formatter can retrieve data both from the operation context and the parent contexts of operation context.
To use the JSON formatter for AJAX requests, you must first define the JSON formatter and then reference the JSON formatter in the AJAX request operation. For information on how to define the JSON formatter, refer to Defining the request data format.
The example below is an example of a reference to a JSON formatter in an AJAX request operation. Note that in the example, the value of the unNamed attribute of the JSON formatter tag is set to false. If the unNamed attribute is set to true, the data will not be transformed to a JSON string for the AJAX request response.
Example of a reference to a JSON formatter in an AJAX request operation
This graphic is described in the surrounding text.
Go up to
Tasks