MVC-11 (bottom). jquery.tmpl.js receive JSON type data loops

Source: Internet
Author: User

Continue mvc-11 (UP). dto:http://www.cnblogs.com/tangge/p/3840060.html

Jquery.tmpl.js Download: http://pan.baidu.com/s/1o68w7Ke

1. Front Desk

Index.cshtml

@{Viewbag.title ="Student List";} @section headsection{    <Scripttype= "Text/x-jquery-tmpl"ID= "Trtemp" > <TR> <th>${StudentID}</th> <th>${Cid}</th> <th>${Name}</th> <th>${Gender}</th> <th>Operation</th> </TR> </Script> <Scripttype= "Text/javascript" >$(function() {            //0. Turn off jquery's browser cache$.ajaxsetup ({cache:false});        Loadpagelist (1);                }); //Request data asynchronously based on page numberfunctionloadpagelist (pageIndex) {$.get ("/stu/list/"+ PageIndex,NULL, function(jsondata) {if(jsondata.statu=="OK") {                    //alert (jsondata.msg); $("#trtemp"). Tmpl (JsonData.Data.PageData). AppendTo ("#tableList");            } alert (JSONDATA.MSG); },"JSON"); }    </Script>}<TableID= "Tablelist"Border= "1"cellspacing= "0"cellpadding= "0"width= "100%" > <TR> <th>ID</th> <th>class name</th> <th>name</th> <th>Sex</th> <th>Operation</th> </TR></Table>

But to make an error

TypeError: $ (...). Tmpl is not a function

$ ("#trtemp"). Tmpl (JsonData.Data.PageData). AppendTo ("#tableList");

Looking for a long reason, results view page source code

Here, inside the _layout.cshtml, introduce Juqey and Tmpl, then annotate

@Scripts. Render ("~/bundles/jquery")

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.