Skip to content

Instantly share code, notes, and snippets.

@Vlasterx
Created September 25, 2017 13:52
Show Gist options
  • Save Vlasterx/8af48c2172647f2a1fc66a89d2b4b18f to your computer and use it in GitHub Desktop.
Save Vlasterx/8af48c2172647f2a1fc66a89d2b4b18f to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/kubamuy
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var http = new XMLHttpRequest();
var method = 'GET';
var url = 'http://jsonplaceholder.typicode.com/posts';
http.open(method, url);
http.onreadystatechange = function() {
if (http.readyState === XMLHttpRequest.DONE && http.status === 200) {
console.log(JSON.parse(http.responseText));
} else if (http.readyState === XMLHttpRequest.DONE && http.status !== 200) {
console.log('Error loading JSON');
}
};
http.send();
</script>
<script id="jsbin-source-javascript" type="text/javascript">var http = new XMLHttpRequest();
var method = 'GET';
var url = 'http://jsonplaceholder.typicode.com/posts';
http.open(method, url);
http.onreadystatechange = function() {
if (http.readyState === XMLHttpRequest.DONE && http.status === 200) {
console.log(JSON.parse(http.responseText));
} else if (http.readyState === XMLHttpRequest.DONE && http.status !== 200) {
console.log('Error loading JSON');
}
};
http.send();</script></body>
</html>
var http = new XMLHttpRequest();
var method = 'GET';
var url = 'http://jsonplaceholder.typicode.com/posts';
http.open(method, url);
http.onreadystatechange = function() {
if (http.readyState === XMLHttpRequest.DONE && http.status === 200) {
console.log(JSON.parse(http.responseText));
} else if (http.readyState === XMLHttpRequest.DONE && http.status !== 200) {
console.log('Error loading JSON');
}
};
http.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment