Home  >  Q&A  >  body text

node.js - KOA-EJS interaction, frontend, data obtained by ajax, how to use EJS template to render.


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中文网2653 days ago827

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-06-24 09:45:10

    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

    reply
    0
  • Cancelreply