java-script:jquery-fetch
This is an old revision of the document!
JQuery fetch example
This example is using jquery to fetch data from a remote server. See also examples using Java Script async/await, or pure AJAX.
- fetch-jquery-ajax.html
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <div id="content"></div> <script> function loadUsers() { $.ajax({ url: 'https://api.github.com/users', method: 'GET', dataType: 'json', success: function(users) { var html = ''; for (var user of users) { html += `<p>Login: ${user.login}</p> <p>ID: ${user.id}</p> <!-- Rest of the properties... --> <hr>`; } $('#content').html(html); }, error: function(xhr, status, error) { console.error(xhr.responseText); } }); } loadUsers(); </script> </body> </html>
java-script/jquery-fetch.1691069399.txt.gz · Last modified: 2023/08/03 16:29 by odefta