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 loadData(httpMethod, 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(httpMethod, url, true);
- xhr.send('');
- console.log("sent");
- }
- function loadUsers(callbackForReceivingUsers) {
- loadData('GET', "https://kartoteka-project.firebaseio.com/users.json", callbackForReceivingUsers)
- }
- function loadExercises(callbackForReceivingExercises) {
- loadData('GET', "https://kartoteka-project.firebaseio.com/exercises.json", callbackForReceivingExercises)
- }
- window.onload = function () {
- loadUsers(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