node.js - KOA-EJS interaction, frontend, data obtained by ajax, how to use EJS template to render.
PHP中文网
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.

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
習慣沉默

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template