效果图:实现代码: 复制代码 代码如下: 无标题文档 标题 时间 正在加载数据。。。 <BR>$(function(){ <BR>var html=""; <BR>var bgcolor=""; <BR>$.ajax({ <BR>url:"http://www.cnblogs.com/rss", <BR>type:"get", <BR>//dataType:($.browser.msie) ? "text" : "xml", <BR>success:function(data){ <BR>$("item",data).each(function(index,element){ <BR>bgcolor=index%2==0 ?" bgcolor='#F1F1F1' ":" bgcolor='#FFFFFF' "; <BR>html+="<tr "+bgcolor+"><td><a href='"+$(this).find("link").text()+"'>"+FormatContent($(this).find("title").text(),40)+"<td>"+ new Date($(this).find("pubDate").text()).format("yyyy-MM-dd hh:mm:ss");+""; <BR>}); <BR>$("#tbl1 tr:not(':first')").remove();//移除非第一行 <BR>$("#tbl1").append(html);//绑定数据到table <BR>}, <BR>complete:function(){ <BR>$("#loading").hide(); <BR>}, <BR>beforeSend:function(x){ <BR>//x.setRequestHeader("Content-Type", "charset=utf-8"); <BR>$("#loading").show(); <BR>}, <BR>error:function(){ <BR>alert("error"); <BR>} <BR>}); <BR>}); <BR> <BR>/** <BR>* 时间对象的格式化; <BR>*/ <BR>Date.prototype.format = function(format) { <BR>/* <BR>* eg:format="YYYY-MM-dd hh:mm:ss"; <BR>*/ <BR>var o = { <BR>"M+" :this.getMonth() + 1, // month <BR>"d+" :this.getDate(), // day <BR>"h+" :this.getHours(), // hour <BR>"m+" :this.getMinutes(), // minute <BR>"s+" :this.getSeconds(), // second <BR>"q+" :Math.floor((this.getMonth() + 3) / 3), // quarter <BR>"S" :this.getMilliseconds() <BR>// millisecond <BR>} <BR>if (/(y+)/.test(format)) { <BR>format = format.replace(RegExp.$1, (this.getFullYear() + "") <BR>.substr(4 - RegExp.$1.length)); <BR>} <BR>for ( var k in o) { <BR>if (new RegExp("(" + k + ")").test(format)) { <BR>format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] <BR>: ("00" + o[k]).substr(("" + o[k]).length)); <BR>} <BR>} <BR>return format; <BR>} <BR>//格式化标题信息 <BR>function FormatContent(word,length){ <BR>return word.length>length?word.substring(0,length)+"...":word; <BR>} <BR>