Created
March 25, 2015 08:13
-
-
Save juanignaciosl/574655d396d44803de30 to your computer and use it in GitHub Desktop.
table-sql-api.html
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"> | |
<title>HTML Table with CartoDB SQL API</title> | |
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.core.js"></script> | |
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.11/themes/css/cartodb.css" /> | |
</head> | |
<body> | |
<table id="mytable"></table> | |
<script> | |
var table = document.getElementById('mytable'); | |
var sql = cartodb.SQL({ user: 'documentation' }); | |
sql.execute("select adm0name, name from ne_10m_populated_places_simple_1 limit 10") | |
.done(function(data) { | |
data.rows.map(function(r) { | |
var row = document.createElement('tr'); | |
var nameCell = document.createElement('td'); | |
nameCell.innerText = r.name; | |
row.appendChild(nameCell); | |
table.appendChild(row); | |
}); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment