-
Notifications
You must be signed in to change notification settings - Fork 0
jsonpRequest
Mike Byrne edited this page Jan 25, 2022
·
2 revisions
Performs jsonp requests - by writing script tags into the page and setting up the callback function to run on success
- turnObjectToQueryString (handled automatically)
settings object - required:
- url - required - url to send request to
- callback - optional - function to run on response, defaults to "callback"
- data - optional - data object sent as data in the request
- onSuccess - required - what to do on success
- onTimeout - optional - what to do if the request times out
- timeout - optional - time in seconds to wait until assuming timeout, defaults to 5 seconds
- nothing
jsonpRequest({
url: 'https://api.instagram.com/v1/media/shortcode/9lMUPcwbzg',
callback: 'my_callback',
data: {
access_token: "access_token"
},
onSuccess: function(data) {
console.log('success!', data);
},
onError: function() {
console.log('timeout');
},
timeout: 5
});