Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Fetch JSON from a public API $.getJSON('https://api.github.com/repos/jquery/jquery', function (repo) { $('#repo-name').text(repo.full_name); $('#repo-stars').text(repo.stargazers_count + ' stars'); $('#repo-desc').text(repo.description); }) .fail(function (xhr) { console.error('API error:', xhr.status, xhr.statusText); }); // With query parameters $.getJSON('/api/products', { category: 'electronics', limit: 10 }) .done(function (products) { products.forEach(function (p) { $('#product-list').append( '<div class="product"><h4>' + p.name + '</h4></div>' ); }); });
Result
Open