1. Output data to the page through the append Method
/*************************** Obtain enterprise information based on the enterprise ID ****** * *************/objindexpage. getnewqiyeinfo = function () {$. getjson ("/qiye/handler/qiyebookinfo. ashx? Callback =? ", {Qiyeid: configqiyeinfoid. get (), Action: "getnewqiyeinfo"}, function (data) {If (Data = "0") {window. location. herf = "/qiye/index.htm"; return;} else {var qiyeinfo = ""; qiyeinfo + = " "; qiyeinfo + =" <Div id = \ "top_left_div \"> "; qiyeinfo + = "<Div class = \" top_left_title \ ">" + data [0]. name + "</div>"; qiyeinfo + = "<Div class = \" top_left_opentime \ "> lending opening time:" + data [0]. etime + "</div>"; qiyeinfo + = "<Div class = \" top_left_tel \ "> Tel:" + data [0]. tel + "</div>"; qiyeinfo + = "<Div class = \" top_leftimg \ "> <a href = \" "+ data [0]. homepage + "\"> </a> </div> "; qiyeinfo + =" </div> "; $ ("# top_left "). append (qiyeinfo );}});};
2. Use the jquery. tmpl. js plug-in to receive data
Htm writing
<Div id = "bookdiv" class = "bookdiv">
</Div>
<SCRIPT id = "booktmpl" type = "text/html" class = "booktmpl"> // use a script of the "text/html" writing type as a data template.
<DL>
<DT> <a target = "_ blank" href = "/book/book_info.aspx? Id =$ {bookid} & bookcount = 2 "> </a> </DT> // data attribute name $ {}
<DD> <a target = "_ blank" href = "/book/book_info.aspx? Id =$ {bookid} & bookcount = 2 ">$ {bookname. length> 8? Bookname. substring (0, 8) + "... ": Bookname} </a> </DD> // restrict the length of a string.
</Dl>
</SCRIPT>
JS Writing Method
$. Getjson ('/qiye/handler/qiyebookinfo. ashx? Callback =? ', Parameter, function (data ){
If (Data = "0 "){
$ ("# Bookdiv"). Empty ();
VaR nobooktips = "<span id = \" nobooktips \ "> no books in this library </span> ";
$ ("# Bookdiv"). append (nobooktips );
} Else {
$ ("# Bookdiv"). Empty ();
$ ("# Booktmpl"). Render (data). appendto ("# bookdiv"); // Add data to the template and insert it to the parent node.
}
});
3. Use of paging events
Use pageswidget. js plug-in
******** ****************/
Objindexpage. getqiyelist = function (){
$ ("# Listinfopages"). Empty (); // clear the DIV of the page number
VaR pagesize = 12; // number of data displayed
VaR parameter = objindexpage. getsql (); // query Condition
Parameter. qiyeid = configqiyeinfoid. Get (); // parameter ~
VaR icount = 0;
Function getcount (){
Parameter. Action = "getqiyebookcount ";
$. Ajaxsetup ({cache: true });
$. Ajaxsetup ({async: false });
$. Getjson ('/qiye/handler/qiyebookinfo. ashx? & Callback =? ', Parameter, function (data ){
Icount = data;
});
Return icount; // The total number of returned data. The page is displayed based on the quantity and the number displayed on each page.
}
Function getbooktoqiyelist (pageindex ){
Parameter. pageindex = pageindex; // page number
Parameter. pagesize = pagesize;
Parameter. Action = "getqiyebooklist ";
$. Getjson ('/qiye/handler/qiyebookinfo. ashx? Callback =? ', Parameter, function (data ){
If (Data = "0 "){
$ ("# Bookdiv"). Empty ();
VaR nobooktips = "<span id = \" nobooktips \ "> no books in this library </span> ";
$ ("# Bookdiv"). append (nobooktips );
} Else {
$ ("# Bookdiv"). Empty ();
$ ("# Booktmpl"). Render (data). appendto ("# bookdiv ");
}
});
}
VaR ibooktocoffeecount = getcount ();
VaR buttontextarray = new array ("first", "last", "& lt;", "& gt ;");
VaR pagesparam = {// parameters required by the pageswidget. js plug-in are not written in detail.
Buttontext: buttontextarray,
Panelid: 'listinfopages ',
Count: ibooktocoffeecount,
Pagesize: pagesize,
Searchtext: false,
Firstlastpages: false,
Mousemove: True,
Ajaxfn: getbooktoqiyelist
};
VaR opages = createpageswidget (pagesparam );
Getbooktoqiyelist (1 );
};