jquery¿çÓò»ñÈ¡Êý¾ÝÒÔ¼°·ÖÒ³
½ñÌì×öÁËÒ»¸öjquery¿çÓò»ñÈ¡josnÊý¾ÝµÄ¹¦ÄÜ£¬Í¬Ê±¶Ô»ñÈ¡µÄÊý¾Ý½øÐзÖÒ³¡£¿´´úÂ룺
html ´úÂ룺
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>ÎÞ±êÌâÒ³</title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> var PageSize=2;//ÿҳÏÔʾÊýÁ¿ jQuery(function() { ShowPage("1"); }); jQuery(function(){ jQuery.getJSON("http://91jquery.com/GetData.ashx?jsoncallback=?",{hid:'1007',hName:escape('°¬Ï£'),p:'1',pagenum:PageSize},function(data) { var jnData = data['d'];//»ñÈ¡Êý¾Ý var getdata1=""; //չʾ²éѯ³öÀ´µÄÊý¾Ý jQuery.each(jnData,function(i){ getdata1+="<a href='Skins.aspx?id="+jnData[i].ID+"' title="+jnData[i].title1+" target=\"_blank\"><div class=\"list2 padding_10 dsli1 sizcache=\"6\" sizset=\"245\" bindex=\"1\"\"><img width=\"120\" height=\"120\" border=\"0\" src=\"http://lolpf.uuu9.com/skinImage /"+jnData[i].pic+"\"><p>"+jnData[i].title1+"<br /><em class= \"f_yel\">ËùÊôÓ¢ÐÛ£º</em>"+jnData[i].hname+"<br /><em class=\"f_yel\">ϲ»¶¶È£º</em>"+jnData[i].score+"</p><span class=\"title8bg\"& gt;</span><span class=\"title8\">"+jnData[i].title+"</span></div></a>\n"; }); jQuery("#we").html(getdata1); Getpage(data['count'],1); }) }) //·ÖÒ³µÄÑùʽչʾ function Getpage(count,page) { var recordCount =count;//¼Ç¼×ÜÊý var PageIndex=page; //µ±Ç°Ò³ if (PageIndex < 1) { PageIndex = 1; } var pageCount =GetPageCount(count);//×ÜÒ³Êý if (PageIndex > pageCount && pageCount != 0) { PageIndex = pageCount; } var fengye="Ò³´Î£º"+PageIndex+"/"+pageCount+" ÿҳ"+PageSize+"Ìõ "+SetPage(pageCount,PageIndex)+""; jQuery("#showp").html(fengye); } //¼ÆËã×ÜÒ³Êý function GetPageCount(count) //×ÜÒ³Êý { var pCount = count / PageSize; if (count % PageSize != 0) { pCount++;} return pCount; } //µã»÷ÉÏÒ»Ò³¡¢ÏÂÒ»Ò³ÊÇ´¥·¢¸Ãº¯Êý function go(page) { var getdata2=""; jQuery.getJSON("http://91jquery.com/GetpfData.ashx?jsoncallback=?",{hid:'1007',hName:escape('°¬Ï£'),p:page,pagenum:PageSize}, function(data){ var jnData = data['d']; jQuery.each(jnData,function(i){ getdata2+="<a href='Skins.aspx?id="+jnData[i].ID+"' title="+jnData[i].title1+" target=\"_blank\"><div class=\"list2 padding_10 dsli1 sizcache=\"6\" sizset=\"245\" bindex=\"1\"\"><img width=\"120\" height=\"120\" border=\"0\" src=\"http://lolpf.uuu9.com/skinImage /"+jnData[i].pic+"\"><p>"+jnData[i].title1+"<br /><em class= \"f_yel\">ËùÊôÓ¢ÐÛ£º</em>"+jnData[i].hname+"<br /><em class=\"f_yel\">ϲ»¶¶È£º</em>"+jnData[i].score+"</p><span class=\"title8bg\"& gt;</span><span class=\"title8\">"+jnData[i].title+"</span></div></a>\n"; }); jQuery("#we").html(getdata2); Getpage(data['count'],page); }) } //Ñùʽ×Ô¶¨Òå function SetPage(iMaxPage,iCurrPage) { if (iCurrPage < 1) iCurrPage = 1; if (iCurrPage > iMaxPage) iCurrPage = iMaxPage; var sTemp = ""; if (iCurrPage > 1) { if (iCurrPage < iMaxPage) { sTemp += "<A onclick=go("+(iCurrPage - 1)+")>ÉÏÒ»Ò³</A><A onclick=go(" + (iCurrPage + 1) + ")> 1 ÏÂÒ»Ò³</A>"; } else { sTemp += "<A onclick=go("+ (iCurrPage - 1)+")>ÉÏÒ»Ò³</A> Ä©Ò³"; } } else { if (iCurrPage < iMaxPage) { sTemp += "Ê×Ò³ <A onclick=go("+(iCurrPage + 1)+")> ÏÂÒ»Ò³</A>"; } else { sTemp += "Ê×Ò³ Ä©Ò³</A>"; } } return (sTemp); } </script> </head> <body> <div class="w620 clearfix" id="we"></div> <div id="showp"></div> </body> </html>
ºǫ́һ°ã´¦Àí³ÌÐò£º
Ö÷ÒªÊǰѸù¾ÝÌõ¼þ²éѯ³öÀ´µÄÓï¾ä¹¹Ôì³Éjosn¸ñʽ Êä³ö.
<%@ WebHandler Language="C#" Class="GetpfData" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; using System.Text; public class GetpfData : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string hid = context.Request["hid"].ToString(); string hname =HttpUtility.UrlDecode(context.Request["hName"].ToString()); int num=Convert.ToInt32(context.Request["pagenum"].ToString()); int page=Convert.ToInt32(context.Request["p"].ToString()); SqlParameter[] paremeter = { new SqlParameter("@hid",SqlDbType.Int) }; paremeter[0].Value = hid; int id = (int)SqlHelper.ExecuteScalar(CommandType.Text, "select ID from Hero where hid=@hid",paremeter); int count = (int)SqlHelper.ExecuteScalar("select count(*) from Skin where Name=" + id);//²éѯ×ܼǼÊý; //²éѯҪÏÔʾµÄÊý¾Ý; string sql = "select top " + num + " * from Skin where Name="+id+" and id not in(select top " + num * (page-1) + " id from Skin where Name="+id+" order by id desc) order by id desc"; DataSet ds = SqlHelper.ExecuteDataset(sql); //¹¹Ôìjson¸ñʽ; StringBuilder sb = new StringBuilder(); sb.Append("["); for (int i = 0; i <ds.Tables[0].Rows.Count; i++) { sb.Append("{"); sb.AppendFormat("'ID':'{0}','title':'{1}','title1':'{2}','pic':'{3}','score':'{4}','hname':'{5}','page':'{6}'", ds.Tables[0].Rows[i]["id"].ToString(), ds.Tables[0].Rows[i]["SkinTitle"].ToString().Length > 9 ? StringHelper.GetLeftStr(ds.Tables[0].Rows[i]["SkinTitle"].ToString(), 9) : ds.Tables[0].Rows[i]["SkinTitle"].ToString(), ds.Tables[0].Rows[i]["SkinTitle"].ToString(), ds.Tables[0].Rows[i]["Skinpic"].ToString(), ds.Tables[0].Rows[i]["Score"].ToString(), hname, page); sb.Append("}"); if (i < ds.Tables[0].Rows.Count - 1) { sb.Append(","); } } sb.Append("]"); string data = sb.ToString(); string callback = context.Request.QueryString["jsoncallback"]; data = "{d:" + data + ",count:" + count + "}"; context.Response.Write(callback+"("+data+")"); context.Response.End(); } public bool IsReusable { get { return false; } } }
˼·ºÜ¼òµ¥£¬¾ÍÊÇÿ´Î²éѯ¸øºǫ́´«ÈëÒª²éѯµÄ²îÊý£¬ÔÙ°ÑResponse.Write£¨£©³öÀ´µÄÊý¾Ý½øÐÐÖØеÄչʾ¡£
ÕâÑù×öÓкܴóÎÊÌâµÄ£¬Èç¹û·ÃÎÊÁ¿·Ç³£´óµÄ»°£¬·þÎñÆ÷»áÊܲ»Á˵ġ£½â¾ö·½·¨£º
1¡¢¼ÓÉÏ»º´æ¡£
2¡¢½«Òª²éѯµÄjsonÊý¾ÝÉú³ÉjsÎļþ£¬´ÓjsÎļþ²éѯÐèÒªµÄÊý¾Ý¡££¨µ«ÕâÑùÊý¾ÝµÄʵʱ¸üоͲ»ÐÐÁ˵ģ©¡£
¶ÔÒª´¦ÀíµÄÊý¾Ý¸üÐÂÊǺܿìÇé¿öϽ¨ÒéÑ¡ÔñµÚ¶þÖÖ·½·¨ÊǺܲ»´íµÄ¡£
ÍƼöÐÅÏ¢
- jqueryʵÏÖÍøվͼƬÀÁ¼ÓÔØ´úÂë
- jQuery Tooltips²å¼þ
- jQueryµÄ.bind()¡¢.live()ºÍ.delegate(....
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- Ä㲻ϲ»¶»ðºü£¬µ«ÓÖϲ»¶firebug£¬ÄǾ͸úÎÒÒ»ÆðÀ´ÔÚIEÉÏ....
- ¸ù¾ÝÏÔʾÆ÷·Ö±æÂʵ÷ÕûÒ³ÃæÏÔʾµÄJavascript½Å±¾
- jQuery дµÄ·ÂÐÂÀË΢²© ÏòϹö¶¯Ð§¹û¡¾×ªÔØ¡¿
- ͨÓõÄJqueryÑ¡ÔñÆ÷
- jQuery ½áºÏ Json Ìá½»Êý¾Ýµ½Webservice£¬....
- ×ÔÖÆjQueryÖÇÄÜÌáʾ²å¼þһö
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- js»ñÈ¡srcÖд«µÝµÄ²ÎÊý
- jqueryʵÏÖÍøվͼƬÀÁ¼ÓÔØ´úÂë
- ÈÃä¯ÀÀÆ÷ÆÁ±ÎµôJavaScriptµÄ³ö´íÌáʾ
- github²»ÄܼÓÔØcss¡¢js½â¾ö°ì·¨
- ÎÒÖªµÀµÄJavaScript -- Éè¼Æģʽ(ÇŽÓ)Ó¦ÓÃÖ® ¨C ....
- 15¸öÖµµÃ¿ª·¢ÈËÔ±¹Ø×¢µÄjQuery¿ª·¢¼¼ÇɺÍÐĵÃ
- dz̸JavascriptÃæÏò¶ÔÏó±à³Ì
- JS¼òµ¥¶¯»·â×°
- JavaScript³õѧÕßӦעÒâµÄÆ߸öϸ½Ú
- jQuery Tooltips²å¼þ
ÆÀÂÛ