Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
With our server all built, what do you say we give it a whirl? Let’s first create a src directory that contains a single file, application.coffee, with these contents:
Example: (source: final/src/application.coffee)
$ ->
$("body").html("Hello from jQuery and Node!!")
Example: (source: final/src/application.js)
(function() {
$(function() {
return $("body").html("Hello from jQuery and Node!!");
});
}).call(this);
For those of you who aren’t big jQuery8 folks, this code will replace the body of the HTML file with “Hello from jQuery and Node!!” after the DOM9 has been loaded.
Now, in our public directory let’s create an index.html file:
Example: (source: final/public/index.html)
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Node.js</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="/javascripts/application.js" type="text/javascript"></script>
</head>
<body>
Hello from Node!!
</body>
</html>