Last active
August 29, 2015 14:16
-
-
Save mapsam/0811545938dd1f68595e to your computer and use it in GitHub Desktop.
Script that makes a call to the Census geocoding API when the page loads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<!-- | |
here we are including the jQuery library specifically to use | |
the `$.ajax()` function for making a call to the Census API | |
--> | |
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<style> | |
body { | |
background: steelblue; | |
} | |
</style> | |
</head> | |
<body> | |
<script> | |
var address = '500 Yale Avenue North, Seattle, WA 98109'; | |
// this is the jQuery ajax function, that allows us to make a | |
// call to another URL. | |
$.ajax({ | |
url: 'http://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address='+address+'&benchmark=4&format=jsonp', | |
dataType: 'jsonp', | |
success: function(response) { | |
console.log(response); | |
}, | |
error: function(error) { | |
console.log(error); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment