Skip to content

Instantly share code, notes, and snippets.

@jameslaneconkling
Last active August 29, 2015 14:17
Show Gist options
  • Save jameslaneconkling/2e23a3f25f59a829ed31 to your computer and use it in GitHub Desktop.
Save jameslaneconkling/2e23a3f25f59a829ed31 to your computer and use it in GitHub Desktop.
Test ajax requests
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no" />
</head>
<body>
<h1>Testing Ajax</h1>
<script>
// var url = 'http://osm.moabi.org/api/0.6/tiles.json';
var url = 'http://tasks.hotosm.org/project/920/tasks.json';
var xmlhttp = new XMLHttpRequest();
var data = undefined;
console.log('sending ajax request');
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 ) {
if(xmlhttp.status == 200){
console.log('successful');
data = xmlhttp.responseText;
}
else {
console.log('error');
}
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
console.log('sent ajax request');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment