Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var getHTML = function ( url, callback ) {
  2.     // Feature detection
  3.     if ( !window.XMLHttpRequest ) return;
  4.    
  5.     var xhr = new XMLHttpRequest();
  6.  
  7.     xhr.onreadystatechange = function() {
  8.     if (this.readyState == 4 && this.status == 200) {
  9.             callback(this.response);
  10.         }
  11.     };
  12.  
  13.     // Get the HTML  
  14.     xhr.open( 'GET', url, true );
  15.     xhr.responseType = 'json';
  16.     xhr.send();
  17. };
  18.  
  19. getHTML('https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Tom_Clancy%27s_The_Division_2&rvsection=0&origin=*', function(jsonResponse) {
  20.     var searchString = jsonResponse.query.pages['56786234'].revisions[0]['*'];
  21.     document.querySelector("h1").innerHTML = searchString.split('| released = ')[1].split('{')[0];
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement