API Docs for: 3.18.1

JSONPRequest Class

Defined in: jsonp/js/jsonp.js:4
Module: jsonp-url
Parent Module: jsonp

Provides a JSONPRequest class for repeated JSONP calls, and a convenience method Y.jsonp(url, callback) to instantiate and send a JSONP request.

Both the constructor as well as the convenience function take two parameters: a url string and a callback.

The url provided must include the placeholder string "{callback}" which will be replaced by a dynamically generated routing function to pass the data to your callback function. An example url might look like "http://example.com/service?callback={callback}".

The second parameter can be a callback function that accepts the JSON payload as its argument, or a configuration object supporting the keys:

  • on - map of callback subscribers
    • success - function handler for successful transmission
    • failure - function handler for failed transmission
    • timeout - function handler for transactions that timeout
  • format - override function for inserting the proxy name in the url
  • timeout - the number of milliseconds to wait before giving up
  • context - becomes this in the callbacks
  • args - array of subsequent parameters to pass to the callbacks
  • allowCache - use the same proxy name for all requests? (boolean)

Item Index

Properties

Methods

_defaultCallback

(
  • url
  • config
)
Function

Provided by the jsonp module.

Defined in jsonp/js/jsonp.js:108

Override this method to provide logic to default the success callback if it is not provided at construction. This is overridden by jsonp-url to parse the callback from the url string.

Parameters:

  • url String

    the url passed at construction

  • config Object

    (optional) the config object passed at construction

Returns:

send

(
  • args
)
chainable

Provided by the jsonp module.

Defined in jsonp/js/jsonp.js:121

Issues the JSONP request.

Parameters:

  • args Any multiple

    any additional arguments to pass to the url formatter beyond the base url and the proxy function name

Properties