FlyJSONP is a small JavaScript library, that allows you to do cross-domain GET
and POST
requests with remote services that support JSONP
, and get a JSON
response. Have a look at the demo to see it in action, or check out get started guide for usage instructions, and examples.
GET
, as well as POST
requests, with JSON
response. POST
requests pass through YQL.GET
requests.To get started, first download FlyJSONP, and add it to your code. Then simply call init
method to setup the initial options.
<script src="https://github.com/alotaiba/FlyJSONP/raw/master/path/to/flyjsonp.js"></script>
<script>
FlyJSONP.init({debug: true});
</script>
To issue a cross-domain GET
request, you call the get
method. It accepts number of options, and calls success
callback when provided, with JSON
response.
FlyJSONP.get({
url: 'http://storify.com/xdamman.json',
success: function (data) {
console.log(data);
},
error: function (errorMsg) {
console.log(errorMsg);
}
});
To issue a cross-domain POST
request, you call the post
method. It accepts number of options, and calls success
callback when provided, with JSON
response. To get around cross-domain issues for POST
requests, FlyJSONP uses YQL to send the request and retrieve the response.
FlyJSONP.post({
url: 'http://storify.com/story/new',
parameters: {
username: 'your-username',
api_key: 'secret-api-key',
title: 'FlyJSONP',
description: 'Testing it out'
},
success: function(data) {
console.log(data);
}
});
FlyJSONP is a project of Abdulrahman Al-Otaiba, the project is dual-licensed under GNU GPLv3, and MIT. See LICENSE for more details.
I would like to thank the following people, and give them credit for their awesome work: