Skip to content
A simple JSONP implementation
JavaScript
Branch: master
Clone or download
Latest commit 7903989 Oct 31, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Update basic.js Mar 5, 2015
.gitignore Release 0.0.1 Jul 4, 2012
.travis.yml add travis/zuul/saucelabs testing Feb 5, 2015
.zuul.yml add travis/zuul/saucelabs testing Feb 5, 2015
History.md Release 0.2.1 Oct 31, 2016
Readme.md Update Readme.md Mar 5, 2015
bower.json Release 0.2.1 Oct 31, 2016
component.json Release 0.2.1 Oct 31, 2016
index.js Update index.js Feb 27, 2015
package.json Release 0.2.1 Oct 31, 2016

Readme.md

jsonp

A simple JSONP implementation.

saucelabs

Installation

Install for node.js or browserify using npm:

$ npm install jsonp

Install for component(1) using component:

$ component install LearnBoost/jsonp

Install for browser using bower:

$ bower install jsonp

API

jsonp(url, opts, fn)

  • url (String) url to fetch
  • opts (Object), optional
    • param (String) name of the query string parameter to specify the callback (defaults to callback)
    • timeout (Number) how long after a timeout error is emitted. 0 to disable (defaults to 60000)
    • prefix (String) prefix for the global callback functions that handle jsonp responses (defaults to __jp)
    • name (String) name of the global callback functions that handle jsonp responses (defaults to prefix + incremented counter)
  • fn callback

The callback is called with err, data parameters.

If it times out, the err will be an Error object whose message is Timeout.

Returns a function that, when called, will cancel the in-progress jsonp request (fn won't be called).

License

MIT

You can’t perform that action at this time.