The goog.net.IframeIo Class

goog.net.IframeIo
> goog.events.EventTarget
> goog.Disposable

goog.net.IframeIo()

Class for managing requests via iFrames.

.FRAME_NAME_PREFIX {string}

Prefix for frame names

.IFRAME_DISPOSE_DELAY_MS {number}

The number of milliseconds after a request is completed to dispose the iframes. This can be done lazily so we wait long enough for any processing that occurred as a result of the response to finish.

.INNER_FRAME_SUFFIX {string}

Suffix that is added to inner frames used for sending requests in non-IE browsers

The goog.net.IframeIo.IncrementalDataEvent Class

Class for representing incremental data events. … more

.abort(opt_failureCode)

Abort the current Iframe request

opt_failureCode {goog.net.ErrorCode=}
Optional error code to use - defaults to ABORT.

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.getErrorChecker()

Gets the callback function used to check if a loaded IFrame is in an error state.

returns {Function}
A callback that expects a document object as it's single argument.

.getIframeByName(fname)

Find an iframe by name (assumes the context is goog.global since that is where IframeIo's iframes are kept).

fname {string}
The name to find.
returns {HTMLIFrameElement}
The iframe element with that name.

.getInstanceByName(fname)

Find an instance of the IframeIo object by name.

fname {string}
The name to find.
returns {goog.net.IframeIo}
The instance of IframeIo.

.getLastCustomError()

Gets the last custom error.

returns {Object}
Last custom error.

.getLastError()

Gets the last error message.

returns {string}
Last error message.

.getLastErrorCode()

Gets the last error code.

returns {goog.net.ErrorCode}
Last error code.

.getLastUri()

Get the uri of the last request.

returns {goog.Uri}
Uri of last request.

.getParentEventTarget()

Inherited from goog.events.EventTarget .

Returns the parent of this event target to use for bubbling.

returns {goog.events.EventTarget}
The parent EventTarget or null if there is no parent.

.getResponseHtml()

Returns the last response html (i.e. the innerHtml of the iframe).

returns {?string}
Result from the server.

.getResponseJson()

Parses the content as JSON. This is a safe parse and may throw an error if the response is malformed. Use goog.json.unsafeparse(this.getResponseText()) if you are sure of the state of the returned content.

returns {Object}
The parsed content.

.getResponseText()

Returns the last response text (i.e. the text content of the iframe). Assumes plain text!

returns {?string}
Result from the server.

.getResponseXml()

Returns the document object from the last request. Not truely XML, but used to mirror the XhrIo interface.

returns {HTMLDocument}
The document object from the last request.

.getTimeoutInterval()

Returns the number of milliseconds after which an incomplete request will be aborted, or 0 if no timeout is set.

returns {number}
Timeout interval in milliseconds.

.handleIncrementalData(win, data)

Handles incremental data and routes it to the correct iframeIo instance. The HTML page requested by the IframeIo instance should contain script blocks that call an externed reference to this method.

win {Window}
The window object.
data {Object}
The data object.

.isActive()

returns {boolean}
True if a transfer is in progress.

.isComplete()

returns {boolean}
True if transfer is complete.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.isSuccess()

returns {boolean}
True if transfer was successful.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.send(uri, opt_callback, opt_method, opt_noCache, opt_data)

Static send that creates a short lived instance of IframeIo to send the request.

uri {goog.Uri|string}
Uri of the request, it is up the caller to manage query string params.
opt_callback {Function=}
Event handler for when request is completed.
opt_method {string=}
Default is GET, POST uses a form to submit the request.
opt_noCache {boolean=}
Append a timestamp to the request to avoid caching.
opt_data {Object|goog.structs.Map=}
Map of key-value pairs that will be posted to the server via the iframe's form.

.sendFromForm(form, opt_uri, opt_noCache)

Sends the data stored in an existing form to the server. The HTTP method should be specified on the form, the action can also be specified but can be overridden by the optional URI param. This can be used in conjunction will a file-upload input to upload a file in the background without affecting history. Example form:

   <form action="/server/" enctype="multipart/form-data" method="POST">
     <input name="userfile" type="file">
   </form>
 
form {HTMLFormElement}
Form element used to send the request to the server.
opt_uri {string=}
Uri to set for the destination of the request, by default the uri will come from the form.
opt_noCache {boolean=}
Append a timestamp to the request to avoid caching.

.setErrorChecker(fn)

Sets the callback function used to check if a loaded IFrame is in an error state.

fn {Function}
Callback that expects a document object as it's single argument.

.setParentEventTarget(parent)

Inherited from goog.events.EventTarget .

Sets the parent of this event target to use for bubbling.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.setTimeoutInterval(ms)

Sets the number of milliseconds after which an incomplete request will be aborted and a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no timeout is set.

ms {number}
Timeout interval in milliseconds; 0 means none.