https://github.com/dafrok/getjsonp
A simpler helper function to get JSON data from another server.
https://github.com/dafrok/getjsonp
Last synced: 3 months ago
JSON representation
A simpler helper function to get JSON data from another server.
- Host: GitHub
- URL: https://github.com/dafrok/getjsonp
- Owner: Dafrok
- License: mit
- Created: 2017-04-20T12:16:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T07:18:25.000Z (over 9 years ago)
- Last Synced: 2025-12-28T22:57:39.385Z (7 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# getJSONP
A simpler helper function to get JSON data from another server.
[Download getJSONP](https://github.com/cferdinandi/getJSONP/archive/master.zip)
## Getting Started
### 1. Include getJSONP on your site.
Include the code in your script, or load it as an external file.
```js
var getJSONP = function ( url, callback ) {
...
};
```
### 2. Fetch your JSON data.
Pass in the URL to fetch data from, as well as the name of a callback function to pass the data to.
```js
// Callback function
var logAPI = function ( data ) {
console.log( data );
};
// Get JSON
getJSONP( 'https://jsonplaceholder.typicode.com/posts/10', 'logAPI' );
```
## Browser Compatibility
getJSONP works in all modern browsers, and IE 6 and above.
## How to Contribute
Please review the [contributing guidelines](CONTRIBUTING.md).
## License
The code is available under the [MIT License](LICENSE.md).