gaurav jain
gaurav jain

Reputation: 1345

returning data from server to an ajax request sent in client side javascript

app.get('/documents/:id.:format?', function(req, res) {
   **dataTobeSentToClientSideJavaScript** = processRequest (req);
   ... 
})

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?

Upvotes: 0

Views: 1091

Answers (1)

Gal Ben-Haim
Gal Ben-Haim

Reputation: 17793

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

Upvotes: 1

Related Questions