Fork me on GitHub

I/O

Allows you to make asynchronous HTTP (Ajax) requests.


Getting Started

First load the seed and CSS files, if you haven't yet.

<script src="https://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
<link href="https://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet"></link>

Then initialize AlloyUI and load the I/O module.

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

Using I/O

Make an asynchronous request and get the response data.

YUI().use(
  'aui-io-request',
  function (Y) {
    Y.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).

YUI().use(
  'aui-io-request',
  function (Y) {
    Y.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.

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