Just example in
jQuery 4.
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>jQuery API Example</title> </head> <body> <button id="load-posts">Load Posts</button> <ul id="post-list"> </ul> <script src="https://code.jquery.com/jquery-4.1.0.min.js"></script> <script> $(function () { $("#load-posts").on("click", function () { const $list = $("#post-list"); $list.html("<li>Loading...</li>"); $.ajax({ url: "https://jsonplaceholder.typicode.com/posts", method: "GET", data: { _limit: 5 }, // Adds ?_limit=5 to the URL dataType: "json", success: function (posts) { $list.empty(); posts.forEach(function (post) { $list.append(`<li><strong>${post.title}</strong></li>`); }); }, error: function (xhr, status, error) { $list.html(`<li>Error loading posts: ${error}</li>`); } }); }); }); </script> </body> </html>
Where jQuery ?
#jquery #javascript
commit a769a46