public
Created

  • Download Gist
app.js
JavaScript
1 2 3 4 5 6 7 8 9 10
var express = require('express');
var app = express();
 
app.use(express.static(__dirname));
 
app.get('/search', function(req, res){
res.send({ hello : 'world' });
});
 
app.listen(3012);
index.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
$('#search').click(function(){
$.ajax({
type: "GET",
url: "/search",
dataType: "json"
}).done (function (data) {
alert(data);
console.log(data);
});
});
});
</script>
</head>
<body>
<button id="search">click</button>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.