This article mainly introduces jquery, a framework for generating HTML with templates. tmpl Usage Details. If you need a friend, you can refer to the dynamic request data to update the page. This is a very common method, such as dynamic loading of blog comments by pages, weibo rolling loading and timed request loading.
In these cases, the data returned by the dynamic request is generally not formatted as JSON or XML. In short, data is spelled out on the server rather than on the browser. However, from the perspective of the transmission volume, it is not cost-effective to return HTML. In terms of web transmission, JSON rather than XML is used.
The browser generates HTML based on JSON. It is annoying that when the structure is not complex, the structure is complicated and the browser wants to die, you need to carefully write JavaScript code that is barely maintained.
Therefore, jquery. tmpl is one of the frameworks that generate HTML using templates. The following describes the usage of jquery. tmpl in detail.
The following describes how to use it.:
First, we will introduce the template and data. Needless to say, these two must be indispensable.
The template can be defined in two ways. The specific code is given below
The Code is as follows:
Var markup ="
Some content: $ {item }.
"
+ "More content :$ {myValue }.";
$. Template ("movieTemplate", markup );
The Code is as follows: