Skip to content

Instantly share code, notes, and snippets.

@lstrihic
Last active August 29, 2015 14:22
Show Gist options
  • Save lstrihic/86e80714b1b30b794fba to your computer and use it in GitHub Desktop.
Save lstrihic/86e80714b1b30b794fba to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script>
function grabJSON(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var employees = JSON.parse(xmlhttp.responseText);
alert(employees.name);
}
}
xmlhttp.open("GET","json.php",true);
xmlhttp.send();
}
</script>
</head>
<body onload="grabJSON();">
<div id="tekst"></div>
</body>
</html>
<?php
header("Content-Type: application/json");
echo "{\"name\":\"ben\",\"age\":23,\"skills\":[\"php\",\"css\",\"javascript\"]}";
exit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment