The goog.net.CrossDomainRpc Class

goog.net.CrossDomainRpc
> goog.events.EventTarget
> goog.Disposable

goog.net.CrossDomainRpc()

Creates a new instance of cross domain RPC

Header prefix.

.PARAM {string}

Parameter prefix.

.PARAM_ECHO {string}

Parameter to echo prefix.

.PARAM_ECHO_DUMMY_URI {string}

Parameter to echo: dummy resource URI

.PARAM_ECHO_REQUEST_ID {string}

Parameter to echo: request id

.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.

.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.

.getResponseHeader(name)

Gets a response header.

name {string}
Name of response header.
returns {string|undefined}
Value of response header; undefined if not found.

.getResponseJson()

If response is JSON, evaluates it to a JavaScript object and returns it; otherwise returns undefined.

returns {Object|undefined}
JavaScript object if response is in JSON or undefined.

.isDisposed()

Inherited from goog.Disposable .

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

.isSuccess()

returns {boolean}
Whether the request completed with a success.

.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.

.reset()

Removes request iframe used.

.send(uri, opt_continuation, opt_method, opt_params, opt_headers)

Sends a request across domain.

uri {string}
Uri to make request to.
opt_continuation {Function=}
Continuation function to be called when request is completed. Takes one argument of an event object whose target has the following properties: "status" is the HTTP response status code, "responseText" is the response text, and "headers" is an object with all response headers. The event target's getResponseJson() method returns a JavaScript object evaluated from the JSON response or undefined if response is not JSON.
opt_method {string=}
Method of request. Default is POST.
opt_params {Object=}
Parameters. Each property is turned into a request parameter.
opt_headers {Object=}
Map of headers of the request.

.sendRequest(uri, opt_method, opt_params, opt_headers)

Sends a request across domain.

uri {string}
Uri to make request to.
opt_method {string=}
Method of request. Default is POST.
opt_params {Object=}
Parameters. Each property is turned into a request parameter.
opt_headers {Object=}
Map of headers of the request.

.sendResponse(data, isDataJson, echo, status, headers)

Makes response available for grandparent (requester)'s receiveResponse call to pick up by creating a series of iframes pointed to the dummy URI with a payload (value after either ? or #) carrying a chunk of response data and a response info iframe that tells the grandparent (requester) the readiness of response.

data {string}
Response data (string or JSON string).
isDataJson {boolean}
true if data is a JSON string; false if just a string.
echo {Object}
Parameters to echo back "xdpe:request-id": Server that produces the response needs to copy it here to support multiple current XD requests on the same page. "xdpe:dummy-uri": URI to a dummy resource that response iframes point to to gain the domain of the client. This can be an image (IE) or a CSS file (FF) found on the requester's page. Server should copy value from request parameter "xdpe:dummy-uri".
status {number}
HTTP response status code.
headers {string}
Response headers in JSON format.

.setDebugMode(flag)

Sets debug mode to true or false. When debug mode is on, response iframes are visible and left behind after their use is finished.

flag {boolean}
Flag to indicate intention to turn debug model on (true) or off (false).

.setDummyResourceUri(dummyResourceUri)

Sets the URI for a dummy resource on caller's domain. This function is used for specifying a particular resource to use rather than relying on auto detection.

dummyResourceUri {string}
URI to dummy resource on the same domain of caller's page.

.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).

.setUseFallBackDummyResource(useFallBack)

Sets whether a fallback dummy resource ("/robots.txt" on Firefox and Safari and current page on IE) should be used when a suitable dummy resource is not available.

useFallBack {boolean}
Whether to use fallback or not.