fra98_

xmlhttprequest

May 6th, 2021
481
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function load(data) {
  2.     document.getElementById('content').innerHTML = data[0].denominazione + '<br>';
  3. }
  4.  
  5. function success() {
  6.     let data = JSON.parse(this.response);
  7.  
  8.     console.log('Ricevo: ', this.status);
  9.     console.log('Da: ', this.responseURL);
  10.     load(data);
  11. };
  12.  
  13. function error(err) {
  14.     console.log('An Error: ', err);
  15. };
  16.  
  17. var xhr = new XMLHttpRequest();
  18. xhr.onload = success;
  19. xhr.onerror = error;
  20.  
  21. xhr.open('GET', 'https://www.dati.lombardia.it/resource/nmru-kdry.json');
  22. xhr.send();
RAW Paste Data