Data processing returned by Handler

Source: Internet
Author: User
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 );
};



  

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.