当前位置:编程学习 > JS >>

jQuery读取视图内容的方法

html 代码:
<input type=button onclick="GetViewContent()" value="获取视图内容">
<div id="ViewContent"></div>
按钮调用函数,div用来接收函数获取到的视图内容,并显示出来。
在表单的jsheader中加入以下JavaScript函数:
复制代码 代码如下:
function GetViewContent(){
var url = 服务器路径/数据库名称/视图名称?readviewentries"
$.get(url,function(data){
var list = "";
list += "<TABLE border='1' cellspacing='0' cellpadding='3' width='100%'><TR><TD><TABLE width='100%' border='1'>"
if($(data).find("viewentry").size == 0){
} else {
$(data).find("viewentry").each(function(){
if($(this).attr("position") < 11) {
$(this).find("entrydata").each(function(){
if ($(this).attr("name")=="name")
list+="<tr><td>"+$(this).text()+"</td><td>"+$(this).next().text()+"</td><td>"+$(this).next().next().text()+"</td></tr>";
})
}
})
}
list += "</TABLE></TD></TR></TABLE>"
$("#ViewContent").html(list);
});
}

 

补充:网页制作,jquery 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,