Skip to content

Instantly share code, notes, and snippets.

View christophszcz's full-sized avatar
🏠
Working from home

Christopher Szczechowicz christophszcz

🏠
Working from home
View GitHub Profile
@christophszcz
christophszcz / ajax
Last active February 11, 2018 16:14
// GET Boilerplate
const xhr = new XMLHttpRequest(); // xhr is XMLHttpRequest. This line creates a new object
const url = 'http://api-to-call.com/endpoint';
xhr.responseType = 'json'; // response type to json //these 6 lines handle response
xhr.onreadystatechange = function() { // event handler that is called whenever the value of the readyStateproperty changes.
if (xhr.readyState === XMLHttpRequest.DONE) {
console.log(xhr.response);
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<div class="container-fluid main">
<div class="well" id="well">
<div class="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>