This wrapper class provides a set of methods to perform asynchronous HTTP (Ajax) requests.

IMPORTANT

It is recommended to use the static ajax method instead of creating a new instance of ix.Ajax for better support of updates.

Example

// Correct usage
ix.api.request.ajax().request(...);

// Discouraged usage
new ix.api.request.Ajax().request(...);

Hierarchy

  • Ajax

Methods

  • Sends an HTTP request to the server.

    Parameters

    • Optional url: null | string

      The URL of the resource on the server. Can be a relative or absolute URL.

    • Optional settings: IxAjaxSettings

      An optional settings object that configures the Ajax request.

    Returns jqXHR<any> | Deferred<any, any, any>

    A jQuery Deferred object that represents the state of the Ajax request. This object can be used to attach additional callback functions that will be executed when the request is complete.

    Example

    // Example usage: Sending a GET request to a server endpoint and logging the response
    ix.api.request.ajax().request('http://example.com/api/data', {
    dataType: 'json',
    urlParameters: {
    param1: 'value1',
    param2: 'value2'
    }
    }).done(function(data) {
    console.log(data);
    });
  • Request a Groovy file, stored in the current application.

    Parameters

    • groovyFile: string

      Path to a groovy file started after application/${application.guid}/groovy/.

    • settings: IxAjaxSettings

      An optional settings object that configures the Ajax request.

    • Optional appContext: IxControl | HTMLElement

      Element object represents an HTML element.

    Returns Deferred<any, any, any>

    jQuery Deferred object

    Example

    ix.api.request.ajax().requestAppGroovy('newGuid.groovy', {
    dataType: "json",
    data: {
    "hello": "world!"
    },
    success: function (data) {
    Notifier.status.notify(data.guids.join("<br>"));
    }
    }, ix.api.dom.getHtml("<GUID>"));
  • Request a groovy file.

    Parameters

    • groovyFile: string

      Path to a groovy file (should be in the portal groovy directory: <portal>/groovy).

    • settings: IxAjaxSettings

      An optional settings object that configures the Ajax request.

    Returns jqXHR<any> | Deferred<any, any, any>

    jQuery Deferred object

    Example

    ix.api.request.ajax().requestGroovy('groovy/de/uplanet/lucy/samples/newGuid.groovy', {
    dataType: "json",
    data: {
    "hello": "world!"
    },
    success: function (data) {
    Notifier.status.notify(data.guids.join("<br>"));
    }
    });
  • Add the current application page context information (request params e.g. rq_AppGuid and form fields) to the current ix.Ajax object.

    Parameters

    • element: IxControl | HTMLElement

      Element object represents an HTML element or Intrexx control.

    Returns Deferred<any, any, any> | Ajax

    jQuery Deferred object

    Example

    var ixAjax = ix.api.request.ajax();
    ixAjax.setAppContext(ix.api.dom.getHtml("<GUID>"));
    ixAjax.requestGroovy('groovy/de/uplanet/lucy/samples/newGuid.groovy', {
    data: {
    "hello": "world!"
    },
    success: function (data) {
    Notifier.status.notify(data.guids.join("<br>"));
    }
    });