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
- _addJSON static
- _form static
- _iframe static
- _multi_complete static
- _multi_destroy static
- _multi_send static
- _multi_setAttrs static
- _multi_startTimeout static
Methods
_addJSON
-
f
-
s
Adds JSON encoded data to the form.
Parameters:
-
f
ObjectHTML form object.
-
s
String | ObjectThe JSON data or object to serialize.
Returns:
created fields.
_form
-
c
Creates a temporary form, if the caller doesn't provide one.
Parameters:
-
c
ObjectConfiguration object passed to YUI.io().
Returns:
form id
_iframe
-
o
-
c
Creates the iframe used in file upload transactions, and binds the response event handler.
Parameters:
-
o
ObjectTransaction object generated by _iframe().
-
c
ObjectConfiguration object passed to YUI.io().
Returns:
_multi_complete
-
o
-
c
Bound to the iframe's Load event and processes the response data.
Parameters:
-
o
OThe transaction object
-
c
ObjectConfiguration object for the transaction.
Returns:
_multi_destroy
-
id
-
c
Destroy the iframe and temp form, if any.
Parameters:
-
id
NumberTransaction id.
-
c
ObjectConfiguration object for the transaction.
Returns:
_multi_send
-
o
-
uri
-
c
Uploads HTML form data, inclusive of files/attachments, using the iframe created in _iframe to facilitate the transaction.
Parameters:
-
o
OThe transaction object
-
uri
ObjectQualified path to transaction resource.
-
c
ObjectConfiguration object for the transaction.
Returns:
_multi_setAttrs
-
f
-
id
-
uri
-
method
Sets the appropriate attributes and values to the HTML form, in preparation of a file upload transaction.
Parameters:
-
f
ObjectHTML form object.
-
id
ObjectThe Transaction ID.
-
uri
ObjectQualified path to transaction resource.
-
method
StringPOST or GET.
Returns:
_multi_startTimeout
-
o
-
c
Starts timeout count if the configuration object has a defined timeout property.
Parameters:
-
o
ObjectTransaction object generated by _iframe().
-
c
ObjectConfiguration object passed to YUI.io().