API Docs for: 1.0.0
Show:

io~multiresponse Class

Extends the IO base class to enable multiple responses using an iframe as the transport medium. Each response fires the response event. The only events that are fired are the start and end events.

All the YUI 3 IO features are supported, so the request can be sent as either GET (for simple query args) or POST (for anything, even file uploads). The module uses an iframe to send the request and includes a callback parameter. (So you cannot include a parameter named callback.) For each response, the server must send a script block invoking the callback, similar to JSONP. Unlike JSONP, however, requests can only be made to your own server because the callback will reference window.parent. In order to trigger script parsing in all browsers, the first chunk of data that the server writes to the connection must be at least 1024 bytes, and it must be part of the body, so you will need to explicitly send an empty head.

Due to the way that the request data is parsed, it is not safe to send JSON-encoded data using the standard YUI 3 IO methods. However, if you define json in the configuration passed to Y.io(), then the data will be passed to the server under the json parameter. (If you pass an object, it will be serialized with Y.JSON.stringify().)

To keep the iframe after it has finished loading, set debug:true in the configuration passed to Y.io().

Item Index

Methods

Methods

_addJSON

(
  • f
  • s
)
Array private static

Adds JSON encoded data to the form.

Parameters:

  • f Object

    HTML form object.

  • s String | Object

    The JSON data or object to serialize.

Returns:

Array: created fields.

_form

(
  • c
)
String private static

Creates a temporary form, if the caller doesn't provide one.

Parameters:

  • c Object

    Configuration object passed to YUI.io().

Returns:

String: form id

_iframe

(
  • o
  • c
)
Void private static

Creates the iframe used in file upload transactions, and binds the response event handler.

Parameters:

  • o Object

    Transaction object generated by _iframe().

  • c Object

    Configuration object passed to YUI.io().

Returns:

Void:

_multi_complete

(
  • o
  • c
)
Void private static

Bound to the iframe's Load event and processes the response data.

Parameters:

  • o O

    The transaction object

  • c Object

    Configuration object for the transaction.

Returns:

Void:

_multi_destroy

(
  • id
  • c
)
Void private static

Destroy the iframe and temp form, if any.

Parameters:

  • id Number

    Transaction id.

  • c Object

    Configuration object for the transaction.

Returns:

Void:

_multi_send

(
  • o
  • uri
  • c
)
Void private static

Uploads HTML form data, inclusive of files/attachments, using the iframe created in _iframe to facilitate the transaction.

Parameters:

  • o O

    The transaction object

  • uri Object

    Qualified path to transaction resource.

  • c Object

    Configuration object for the transaction.

Returns:

Void:

_multi_setAttrs

(
  • f
  • id
  • uri
  • method
)
Void private static

Sets the appropriate attributes and values to the HTML form, in preparation of a file upload transaction.

Parameters:

  • f Object

    HTML form object.

  • id Object

    The Transaction ID.

  • uri Object

    Qualified path to transaction resource.

  • method String

    POST or GET.

Returns:

Void:

_multi_startTimeout

(
  • o
  • c
)
Void private static

Starts timeout count if the configuration object has a defined timeout property.

Parameters:

  • o Object

    Transaction object generated by _iframe().

  • c Object

    Configuration object passed to YUI.io().

Returns:

Void: