1

Adding some test ajax changes

This commit is contained in:
Alex Yatskov 2014-07-26 15:02:42 +09:00
parent e6999e4063
commit 99673fcb5e
3 changed files with 33 additions and 8 deletions

View File

@ -102,7 +102,6 @@
<script src="grapher.js"></script> <script src="grapher.js"></script>
<script src="projection.js"></script> <script src="projection.js"></script>
<script src="keywords.json"></script>
<script src="data.json"></script> <script src="data.json"></script>
</body> </body>

View File

@ -210,12 +210,37 @@ function onQuery() {
} }
$(document).ready(function() { $(document).ready(function() {
for (var keyword in DATA_KEYWORDS) { // $.ajax({
$('#query').append($('<option></option>', { // url: 'http://localhost:3000/hscd/keywords',
'value': keyword, // type: 'POST',
'text': keyword // contentType: "application/json; charset=utf-8",
})); // dataType: 'script',
} // data: {'foo': 'bar'},
// error: function() { alert('Failed'); },
// success: function(data) { alert(typeof(data)); }
// });
$('#search').click(onQuery); // $.post("http://localhost:3000/hscd/keywords", {}, function(result){ alert(result);}, "json");
// $.ajax({
// url: 'http://twitter.com/status/user_timeline/padraicb.json?count=10',
// dataType: 'script',
// success: function(data) { alert(data); }
// });
$.getJSON('http://localhost:3000/hscd/keywords?callback=?', {'foo': 1}, function(data) {
alert('Data returned ' + Object.keys(data));
});
// for (var keyword in data) {
// $('#query').append($('<option></option>', {
// 'value': keyword,
// 'text': keyword
// }));
// }
// $('#search').click(onQuery);
// }).fail(function(d, textStatus, error) {
// console.error("getJSON failed, status: " + textStatus + ", error: "+error)
// });
}); });

View File

@ -9,6 +9,7 @@ function main() {
var router = express.Router(); var router = express.Router();
router.use('/keywords', function(req, res, next) { router.use('/keywords', function(req, res, next) {
console.log('Requesting keywords');
res.json(keywords); res.json(keywords);
}); });