JavaScript

{dialog.object}ajaxCallback Method

Syntax

{dialog.object}.ajaxCallback(part,rowNum,XbasicFunction [,callbackURL [,additionalData [, options]]]);

Arguments

partstring

In a grid component, part indicates the Grid part (Search, Grid, or Detail View) from which data should be submitted. In a UX Component, this parameter is not used and should be an empty string.

rowstring

In a grid component, row indicates the Grid row from which data should be submitted. In a UX Component, this parameter is not used and should be an empty string.

XbasicFunctionstring

The name of the Xbasic function you want to call on the server.

callbackURLstring

Default = "". This parameter is almost always set to a blank string. It can be used to specify the URL you want to call to handle the callback. For example, you could call a .php, or .asp page to handle the callback. If this value is not blank then the setting for XbasicFunction is ignored.

additionalDatastring

Default = "". Any additional data you want to submit. The data in the controls on the UX Component is automatically submitted. This can be used to submit additional data. Specify a string of name/value pairs. e.g. 'data1=value1&data2=value2'

optionsobject

An object with one or more additional options. Available options include:

submitFormDataboolean

A true/false value. If true, form data will be submitted from the component. Set to false if you do not want to submit form data.

ajaxCallbackTimeoutnumeric

Maximum number of milliseconds to wait for a response from the server. If no response is received, an optional errorFunction can be called.

errorFunctionfunction

Function called if the server does not send a response. A response may not be sent if there is no internet connection or the server cannot be reached.

If the server does not send a response because there was an error when executing the Xbasic function handling the callback, the error function will not be called. To handle Xbasic errors in your callback functions, add error handling logic to capture the Xbasic error and return an error message to the client.

onCompletefunction

Function to call if the callback completes successfully.

deviceOfflineFunctionfunction

Function to call if the device is offline.

getLocationDataboolean

A true/false value. Indicates if the location (latitude and longitude) should be fetched from the browser and submitted to the server.

The e object passed to ajax callback function will contain the location in the following properties: __locationFound - true/false, __locationLatitude - the latitude value, and __locationLongitude - the longitude value.

Not all browsers support fetching the location.

enableHighAccuracyboolean

A true/false value. Indicates if high accuracy should be used when fetching the location. Using high accuracy will take longer and use more power.

timeoutnumeric

Amount of time to wait in milliseconds to fetch the location.

maximumAgenumeric

Maximum time in milliseconds to accept a previously fetched location. A value of 0 means that a new location must be fetched.

flagSaveListDataboolean

A true/false value. If true, list data is submitted to the server.

chunkedResponsesobject

An object with the following properties:

allowboolean

A true/false value. If true, chunked responses will be used.

maxMessagesnumeric

The maximum number of messages to listen for.

maxTimenumeric

The maximum number of seconds to listen for messages.

Description

Does an Ajax callback to a server.

Example

{dialog.object}.ajaxCallback('','','myAjaxCallback1','','data1=value1&data2=value2');

Data from the UX Component is submitted to the server. It is recommended that you use Action Javascript to write the code for you. This can be done by creating an Ajax Callback Action either as a Javascript Action or as Action Javascript for a control's event.

The method has several blank arguments in order to keep the method prototype the same as for the Grid component.

See Also