alemesa
2/10/2017 - 12:38 AM

AJAX Request

AJAX Request

windows.onload = function(){
  
  var http = new XMLHttpRequest();
  
  http.onreadystatechange = function(){
    
    if(http.readyState == 4 && http.status == 200){
      console.log(JSON.parse(http.response));
    }
    
  };
  
  // http.open("GET", url, false);     // this will block the code making it SYNC
  http.open("GET", url, true);         // this will keep running making it ASYNC
  http.send();
  
  
  
  }
  
  
  //JQUERY WAY
  
  $.get(url, function(data){
    
    console.log(data);
    
  });