node.js - KOA-EJS interaction, frontend, data obtained by ajax, how to use EJS template to render.
PHP中文网2017-06-24 09:43:10
0
1
991
At the beginning of the backend, the data passed in was displayed normally. I don’t know how to display the data returned by ajax using an EJS template.
ejs is used for the first rendering, ajax cannot be rendered with ejs
Give me the simplest example
<script>
var test = '<%= val %>'
</script>
After writing this, after your ejs is rendered and you inspect the element, you will find that the ejs syntax val in the js has been rendered as a fixed value
ejs is not an mvvm framework. The purpose of using ejs is to bring some data and reduce requests during the first rendering.
Otherwise, the method is to load the data for the first time, request, load, and then render the data
ejs is used for the first rendering, ajax cannot be rendered with ejs
Give me the simplest example
After writing this, after your ejs is rendered and you inspect the element, you will find that the ejs syntax val in the js has been rendered as a fixed value
ejs is not an mvvm framework. The purpose of using ejs is to bring some data and reduce requests during the first rendering.
Otherwise, the method is to load the data for the first time, request, load, and then render the data