Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>title</title>
- <script>
- var callbackWhenDataGetsBack = function(data) {
- console.log(JSON.parse(data));
- }
- function loadUsers(url, callback) {
- console.log("preparing request");
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- console.log("data received");
- callback(xhr.response);
- }
- }
- xhr.open('GET', url, true);
- xhr.send('');
- console.log("sent");
- }
- window.onload = function () {
- loadUsers("https://kartoteka-project.firebaseio.com/users.json", callbackWhenDataGetsBack);
- };
- </script>
- </head>
- <body>
- <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
- crossorigin="anonymous"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement