Fork me on GitHub

I/O

Allows you to make asynchronous HTTP (Ajax) requests.


Getting Started

First load the seed file, if you haven't yet.

<script src="https://cdn.alloyui.com/1.0.3/aui/aui-min.js"></script>

Then initialize AlloyUI and load the I/O module.

AUI().use(
  'aui-io-request',
  function (A) {
    // code goes here
  }
);

Using I/O

Make an asynchronous request and get the response data.

AUI().use(
  'aui-io-request',
  function (A) {
    A.io.request(
      'example.json',
      {
        on: {
          success: function() {
            var data = this.get('responseData');
          }
        }
      }
    );
  }
);

Configuring I/O

There are some other options that you can pass to your I/O method.

For example, you can specify the type of the request (e.g., xml, json, javascript, text).

AUI().use(
  'aui-io-request',
  function (A) {
    A.io.request(
      'example.xml',
      {
        dataType: 'xml',
        on: {
          success: function() {
            var data = this.get('responseData');
          }
        }
      }
    );
  }
);

Also, you can set cache to false so the current timestamp will be appended to the url, preventing the url from being cached.

AUI().use(
  'aui-io-request',
  function (A) {
    A.io.request(
      'example.xml',
      {
        cache: 'false',
        on: {
          success: function() {
            var data = this.get('responseData');
          }
        }
      }
    );
  }
);
For more information about configuration, check out our API Docs.