node.js - How express passes parameters to the web page rendered by the render() method
伊谢尔伦
伊谢尔伦 2017-06-10 09:48:46
0
1
763

I used a form form to initiate a get request on a page. After routing, I first rendered and opened a page, and then I needed to execute a $.json() method in the js code of the html page itself. So the question is how to put the form The parameters in the form are passed to the rendered page and then called?
app.get('/testAllData',function (req,res) {

var start=req.query.startTime; var end=req.query.endTime; //如何把这两个参数传递到html页面里面? res.render("testAllData.html"); });
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all (1)
学习ing

res.render("testAllData.html",{start:start,end:end});

testAllData.html page where parameters are needed, use
<%=start%>

Supplement: The premise of the above writing method is that your express uses ejs as the template engine.

app.engine('.html', require('ejs').renderFile);

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!