Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>title</title>
  7.  
  8. <script>
  9.  
  10. var callbackWhenDataGetsBack = function(data) {
  11. console.log(JSON.parse(data));
  12. }
  13.  
  14. function loadUsers(url, callback) {
  15. console.log("preparing request");
  16.  
  17. var xhr = new XMLHttpRequest();
  18.  
  19. xhr.onreadystatechange = function () {
  20. if (xhr.readyState === 4) {
  21. console.log("data received");
  22. callback(xhr.response);
  23. }
  24. }
  25.  
  26. xhr.open('GET', url, true);
  27. xhr.send('');
  28. console.log("sent");
  29. }
  30.  
  31. window.onload = function () {
  32. loadUsers("https://kartoteka-project.firebaseio.com/users.json", callbackWhenDataGetsBack);
  33. };
  34. </script>
  35. </head>
  36.  
  37. <body>
  38. <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
  39. crossorigin="anonymous"></script>
  40. </body>
  41.  
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement