Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Load Posts</title>
- <script src="jquery-3.0.0.min.js"></script>
- </head>
- <body>
- <button id="loadPosts">Load Posts from Kinvey</button>
- <script>
- $('#loadPosts').click(function() {
- let USERNAME = "guest"
- let PASSWORD = "123"
- let authBase64 = btoa(USERNAME + ":" + PASSWORD)
- $.ajax({
- method: "GET",
- url: "https://baas.kinvey.com/appdata/kid_S1b_XoIB/knigi",
- headers: {"Authorization": "Basic " + authBase64 },
- success: showPosts,
- error: showError
- })
- })
- function showPosts(data, status) {
- let ul = $('<ul>')
- for (let post of data) {
- ul.append($('<li>').text(
- post.title + " -> " + post.body));
- }
- $('body').append(ul);
- }
- function showError(data,status) {
- let errorMsg = "Error: " + data.responseText;
- $('body').append($('<div>').text(errorMsg));
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement