A simpler helper function to get JSON data from another server.
Include the code in your script, or load it as an external file.
var getJSONP = function ( url, callback ) {
...
};
Pass in the URL to fetch data from, as well as the name of a callback function to pass the data to.
// Callback function
var logAPI = function ( data ) {
console.log( data );
};
// Get JSON
getJSONP( 'https://jsonplaceholder.typicode.com/posts/10', 'logAPI' );
getJSONP works in all modern browsers, and IE 6 and above.
Please review the contributing guidelines.
The code is available under the MIT License.