2.0.10 • Published 7 years ago

lc-jsonp v2.0.10

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

jsonp

jsonp request

Usage

install

npm i lc-jsonp --save

code example(webpack)

var jsonp = require('lc-jsonp');
var url = 'http://www.example.com';
var arg = {id: 1};

jsonp(url, arg)
    .then(function(res){
            console.log(res);
        }
    );

//jsonp is a Promise object, you can use bluebird resolve it and use timeout function.
var Promise = require('bluebird');
var timeout = 300; //milliseconds
Promise.resolve(jsonp(url, arg))
    .timeout(timeout)
    .then(function(res){
            console.log(res);
        }
    ).catch(Promise.TimeoutError, function() {
      console.error('Request time out, do something.');
    });

Warning

  1. This module will occupy a global variable, named window.loadJsonp. Please keep in mind of it.
  2. This module only work for CommonJS. Please use webpack etc to use this module.
  3. Url can not contain query string.
  4. Please include Promise shim if you run it in old browser.

test

Install npm packagesnpm i, then start server npm start, then open url http://localhost:3011/test/test.html in browser.

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

8 years ago