Js deals with the data returned by ajax. How to render it?

which is better to concatenate strings or to use a template engine.

or how to package node rendered with ejs into a static file

May.30,2022

first question: ajax and template engine are two ways of interaction, each has its own advantages and disadvantages, and the application scenarios are not the same.

  • ajax is an asynchronous interaction, which can be partially refreshed. If an error is returned, it will not affect the rendering of other pages. The disadvantage is that manipulating elements requires a large number of selectors or splicing element strings, which is troublesome to develop, but most front-ends have this technology, and the training cost is low
  • .
  • template engine, high development efficiency, fast back-end learning, most front-end can not be maintained, but also need to train template syntax (not easy to use).

take our company as an example. Because the first page is visited frequently, the freemarck template engine is used to compile the page into a static file, add a timer to the generated control class, generate a static file in half an hour, and replace the first page in the project (the cluster needs to add a synchronization mechanism), so that the page can be static. Try to avoid calling the back-end interface
when loading pages, and use ajax interaction on other pages that do not require compatibility with high concurrent loading, which is more flexible

.

second question: node uses ejs to render
you can search for specific instances. There are many downloadable projects on the Internet for rendering static files

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b43b-2c271.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b43b-2c271.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?