Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Cloud 9 ide post data to page not working

Cloud 9 ide post data to page not working


I am developing a small node.js application using express on Cloud 9 ide.

I have a static index.Html page and some routes defined. One of the routes is a post'/getJson', function (req, res) {
    jsonData = fetchData(req.body.selectpicker);
    res.render('index.html', '


'); });

As jade is not supported i just want to pass some html to the static page. Currently using

res.render('index.html', '



How can I render the html on the page?

Problem courtesy of: tjhack


The render() function of the response renders a view and returns the HTML. If you want to render pages, you need a rendering engine such as EJS or Jade. If you're using either of those rendering engines, you can pass the HTML like so:

res.render('index.html, {
  html: '


' });

Since Jade isn't supported (may I ask why?), this is how you'd insert the HTML fragment in EJS.

Solution courtesy of: hexacyanide


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Cloud 9 ide post data to page not working


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription