1

Work on ajax

This commit is contained in:
Alex Yatskov 2014-07-28 10:57:04 +09:00
parent 351ec72299
commit 42aee030e1
4 changed files with 12 additions and 9 deletions

View File

@ -210,12 +210,14 @@ function onQuery() {
}
$(document).ready(function() {
$.getJSON('/node/hscd/keywords', function(data) {
for (var keyword in data) {
$.getJSON('/node/hscd/keywords', function(keywords) {
for (var i = 0; i < keywords.length; ++i) {
$('#query').append($('<option></option>', {
'value': keyword,
'text': keyword
'value': keywords[i],
'text': keywords[i]
}));
}
$('#search').prop('disabled', false);
});
});

View File

@ -40,7 +40,7 @@
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<button class="btn btn-primary" id="search" type="button">
<button class="btn btn-primary" id="search" type="button" disabled="disabled">
<span class="glyphicon glyphicon-search"></span> Search
</button>
</div>
@ -100,9 +100,8 @@
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/fabric/dist/fabric.min.js"></script>
<script src="application.js"></script>
<script src="grapher.js"></script>
<script src="projection.js"></script>
<script src="data.json"></script>
</body>
</html>

View File

@ -10,6 +10,7 @@
"author": "",
"license": "BSD-2-Clause",
"dependencies": {
"express": "~4.5.1"
"express": "~4.5.1",
"underscore": "^1.6.0"
}
}

View File

@ -3,6 +3,7 @@
var express = require('express');
var keywords = require('./db/keywords.json');
var data = require('./db/data.json');
var _ = require('underscore');
function main() {
var app = express();
@ -10,7 +11,7 @@ function main() {
router.use('/keywords', function(req, res, next) {
console.log('Requesting keywords');
res.json(keywords);
res.json(_.keys(keywords));
});
app.use('/hscd', router);