Using the template engine in Ajax

Source: Internet
Author: User

First, overview:
    • Processing response data rendering can use the template engine (which is actually an API to make it easier to render data into HTML)
    • There are many template engines available on the market, so you can refer to
    • It is recommended to use Arttemplate, It uses scoped pre-declared technology to optimize template rendering speed, while supporting NodeJS and browsers.
Second, the template engine steps:

① Select a template engine to download the template engine files

② introduced into the page

③ Prepare a template

④ Prepare a data

⑤ provides a function to integrate templates and data to render the resulting HTML through the template engine's JS

⑥ setting the HTML of the rendered result to the innerHTML of the default element

Iii. reasons for template writing to script
    • If you write to the JS variable, maintenance is inconvenient, cannot wrap, no coloring
    • Written to the Script tab, innerHTML is not displayed on the interface
    • Note: If type is not text/javascript in the script tag, the contents of the tag will not be installed JS file execution
Iv. reference: JavaScript template engine Instance application

Using the template engine in Ajax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.