Skip to content

Lightweight JSONP library for cross-domain ajax calls.

Notifications You must be signed in to change notification settings

sobstel/jsonp.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

jsonp.js

JSONP cross-domain ajax calls written in pure Javascript.

Usage

If using an AMD loader, you need to set up the path config in e.g. require.js so that 'jsonp' resolves to the module's path

require('jsonp', function(jsonp) {

  jsonp.send('url?callback=handleStuff', {
    callbackName: 'handleStuff',
    onSuccess: function(json){
      console.log('success!', json);
    },
    onTimeout: function(){
      console.log('timeout!');
    },
    timeout: 5
  });

});

Notes

You need to add callback name to URL yourself if you need it, eg.

jsonp.send('url?callback=name', {
  callbackName: 'name'
});

About

Lightweight JSONP library for cross-domain ajax calls.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •