Skip to content

Instantly share code, notes, and snippets.

@robertklep
Created April 14, 2013 09:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertklep/5382069 to your computer and use it in GitHub Desktop.
Save robertklep/5382069 to your computer and use it in GitHub Desktop.
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);
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment