app.get('/documents/:id.:format?', function(req, res) { **dataTobeSentToClientSideJavaScript** = processRequest (req); ... })
ajax request from client side javascript
var request = $.ajax({ url: "/documents/xxx", }); request.done(handleResponse);
I am able to receive the request on server side
What code should be written on server side so that I can populate the "handleRespone" object expected in my ajax request above with dataTobeSentToClientSideJavaScript created on server side?
You want to use methods exposed by the response object such as res.write, res.end or res.json
take a look at http://nodejs.org/api/http.html#http_class_http_serverresponse (Node.js API)
and since you're using Express - http://expressjs.com/api.html#res.status