net.Jsonp Extends
Creates a new cross domain channel that sends data to the specified host URL. By default, if no reply arrives within 5s, the channel assumes the call failed to complete successfully.

Inheritance

Constructor

goog.net.Jsonp(uriopt_callbackParamName)

Parameters

uri : goog.Uri | string
The Uri of the server side code that receives data posted through this channel (e.g., "http://maps.google.com/maps/geo").
opt_callbackParamName : string=
The parameter name that is used to specify the callback. Defaults to "callback".

Instance Methods

Public Protected Private
Defined in goog.net.Jsonp
cancel(request)
Cancels a given request. The request must be exactly the object returned by the send method.
Arguments:
request : Object
The request object returned by the send method.
code »
getRequestTimeout() number
Returns the current timeout value, in milliseconds.
Returns: number  The timeout value.
code »
send(opt_payloadopt_replyCallbackopt_errorCallbackopt_callbackParamValue) !Object
Sends the given payload to the URL specified at the construction time. The reply is delivered to the given replyCallback. If the errorCallback is specified and the reply does not arrive within the timeout period set on this channel, the errorCallback is invoked with the original payload. If no reply callback is specified, then the response is expected to consist of calls to globally registered functions. No &callback= URL parameter will be sent in the request, and the script element will be cleaned up after the timeout.
Arguments:
opt_payload : Object=
Name-value pairs. If given, these will be added as parameters to the supplied URI as GET parameters to the given server URI.
opt_replyCallback : Function=
A function expecting one argument, called when the reply arrives, with the response data.
opt_errorCallback : Function=
A function expecting one argument, called on timeout, with the payload (if given), otherwise null.
opt_callbackParamValue : string=
Value to be used as the parameter value for the callback parameter (callbackParamName). To be used when the value needs to be fixed by the client for a particular request, to make use of the cached responses for the request. NOTE: If multiple requests are made with the same opt_callbackParamValue, only the last call will work whenever the response comes back.
Returns: !Object  A request descriptor that may be used to cancel this transmission, or null, if the message may not be cancelled.
code »
setRequestTimeout(timeout)
Sets the length of time, in milliseconds, this channel is prepared to wait for for a request to complete. If the call is not competed within the set time span, it is assumed to have failed. To wait indefinitely for a request to complete set the timout to a negative number.
Arguments:
timeout : number
The length of time before calls are interrupted.
code »

Instance Properties

Defined in goog.net.Jsonp
callbackParamName_ :
This is the callback parameter name that is added to the uri.
Code »
timeout_ :
The length of time, in milliseconds, this channel is prepared to wait for for a request to complete. The default value is 5 seconds.
Code »
uri_ : goog.Uri
The uri_ object will be used to encode the payload that is sent to the server.
Code »

Static Methods

goog.net.Jsonp.addPayloadToUri_(payloaduri) !goog.Uri
Returns URL encoded payload. The payload should be a map of name-value pairs, in the form {"foo": 1, "bar": true, ...}. If the map is empty, the URI will be unchanged.

The method uses hasOwnProperty() to assure the properties are on the object, not on its prototype.

Arguments:
payload : !Object
A map of value name pairs to be encoded. A value may be specified as an array, in which case a query parameter will be created for each value, e.g.: {"foo": [1,2]} will encode to "foo=1&foo=2".
uri : !goog.Uri
A Uri object onto which the payload key value pairs will be encoded.
Returns: !goog.Uri  A reference to the Uri sent as a parameter.
code »
goog.net.Jsonp.cleanup_(iddeleteReplyHandler)
Removes the script node and reply handler with the given id.
Arguments:
id : string
The id of the script node to be removed.
deleteReplyHandler : boolean
If true, delete the reply handler instead of setting it to nullFunction (if we know the callback could never be called again).
code »
goog.net.Jsonp.newErrorHandler_(idpayloadopt_errorCallback) !Function
Creates a timeout callback that calls the given timeoutCallback with the original payload.
Arguments:
id : string
The id of the script node.
payload : Object
The payload that was sent to the server.
opt_errorCallback : Function=
The function called on timeout.
Returns: !Function  A zero argument function that handles callback duties.
code »
goog.net.Jsonp.newReplyHandler_(idreplyCallback) !Function
Creates a reply callback that calls the given replyCallback with data returned by the server.
Arguments:
id : string
The id of the script node.
replyCallback : Function
The function called on reply.
Returns: !Function  A reply callback function.
code »

Static Properties

goog.net.Jsonp.CALLBACKS :
The name of the property of goog.global under which the callback is stored.
Code »
goog.net.Jsonp.scriptCounter_ :
Used to generate unique callback IDs. The counter must be global because all channels share a common callback object.
Code »

Package net

Package Reference