下边的方法是读取数据列表功能
var PageNo=1,PageCount=1,pagesize=10,orderby,yhpl;
function load_yhpl() {
orderby = document.getElementById("sltOrderBy").value;
var url="http://192.168.60.64/wowshop2/AjaxServers/Votes.aspx";
var data ="jsonpcallback=getVotesListJsonp&act=getVotesList&page="+PageNo+"&pagesize="+pagesize+"&orderby="+orderby+"&time="+Math.random(); $.ajax( {
type: "get",
dataType: "jsonp",
jsonp:"jsonpcallback",
url: url,
data: data,
success: function(msg) { }
});
}
function getVotesListJsonp(msg) {
var tmpHtml="<ul>";
var votes = msg.Votes;
$.each(votes, function(i, n)
{
PageCount = n.RowCount;
tmpHtml+="<li class=" + n.CssName + ">";
tmpHtml+="<table width=890 border=0 cellpadding=0 cellspacing=0>"; tmpHtml+="<tr>";
tmpHtml+="<td width=125 valign=middle>第<span class="number">" + n.RowId + "</span>楼</td>";
tmpHtml+="<td width=125 valign=middle><span class="user_id">用户ID:" + n.UserId + "</span></td>";
tmpHtml+="<td width=340 valign=middle class="slogan">广告语:<span class="red">" + n.VotesTitle+ "</span></td>";
tmpHtml+="<td width=100 align=left valign=middle>总票数:<span class="red">" + n.TotalVotes + "</span></td>";
tmpHtml+="<td width=100 align=left valign=middle>周票数:<span class="red">" + n.weekVotes + "</span></td>";
tmpHtml+='<td width=100 align=center valign=middle><input type=button value=投票 class="toupiao_btn" onclick="return setVotes(' + n.VotesId + ');" /></td>'; tmpHtml+="<td id='td_"+n.VostesId+"' width=100 align=center valign=middle><input type='button' title=\"点击复制地址到剪贴板,直接在MSN/QQ上粘贴即可.\" value='邀请好友投票' style='width:90px;' class='toupiao_btn' id=\"btn_InviteFriends_" + n.VotesId + "\" onclick=\"return InviteFriends('" + n.VotesId + "');\" /></td>"; tmpHtml+="</table>";
tmpHtml+="</li>";
tmpHtml+="<li class='ad_con' id='li_VotesContent_" + n.VotesId + "'>广告语创意说明:<span class="huise" style=color:#909090;>" + n.VotesContent + "</span></li>"; });
tmpHtml+="</ul>"; $("#divVotesList").html(tmpHtml);
}
下面的是查询后的jsonp数据:
jsonp1283833223096,getVotesListJsonp({"Votes":[{"RowCount":"1","CssName":"hui_tiao","RowId":"1","VotesId":"41","UserId":"15432","VotesTitle":"又来测试啦","TotalVotes":"13","weekVotes":"2","VotesContent":"又来测试啦又来测试啦"},{"RowCount":"1","CssName":"hui_tiao","RowId":"2","VotesId":"33","UserId":"15427","VotesTitle":"测试6","TotalVotes":"1","weekVotes":"1","VotesContent":"测试1测试1测试1测试1测试1"},{"RowCount":"1","CssName":"hui_tiao","RowId":"3","VotesId":"32","UserId":"15428","VotesTitle":"测试5","TotalVotes":"3","weekVotes":"2","VotesContent":"测试1测试1测试1测试1测试1"}]})
jquery 在 ie6 下 报错,提示缺少},但在ie7/8 FF 下都不会出错.
请各位大虾帮忙.急!在线=
你写的脚本有点问题, 给你改了下:
var PageNo = 1, PageCount = 1, pagesize = 10, orderby, yhpl;
function load_yhpl() {
orderby = document.getElementById("sltOrderBy").value;
var url = "http://192.168.60.64/wowshop2/AjaxServers/Votes.aspx";
var data = "jsonpcallback=getVotesListJsonp&act=getVotesList&page=" + PageNo + "&pagesize=" + pagesize + "&orderby=" + orderby + "&time=" + Math.random(); $.ajax({
type: "get",
dataType: "jsonp",
jsonp: "jsonpcallback",
url: url,
data: data,
success: function(msg) { }
});
}
function getVotesListJsonp(msg) {
var tmpHtml = "<ul>";
var votes = msg.Votes;
$.each(votes, function(i, n) {
PageCount = n.RowCount;
tmpHtml += "<li class=" + n.CssName + ">";
tmpHtml += "<table width=890 border=0 cellpadding=0 cellspacing=0>";
tmpHtml += "<tr>";
tmpHtml += "<td width=125 valign=middle>第<span class=\"number\">" + n.RowId + "</span>楼</td>";
tmpHtml += "<td width=125 valign=middle><span class=\"user_id\">用户ID:" + n.UserId + "</span></td>";
tmpHtml += "<td width=340 valign=middle class=\"slogan\">广告语:<span class=\"red\">" + n.VotesTitle + "</span></td>";
tmpHtml += "<td width=100 align=left valign=middle>总票数:<span class=\"red\">" + n.TotalVotes + "</span></td>";
tmpHtml += "<td width=100 align=left valign=middle>周票数:<span class=\"red\">" + n.weekVotes + "</span></td>";
tmpHtml += '<td width=100 align=center valign=middle><input type=button value=投票 class="toupiao_btn" onclick="return setVotes(' + n.VotesId + ');" /></td>';
tmpHtml += "<td id='td_" + n.VostesId + "' width=100 align=center valign=middle><input type='button' title=\"点击复制地址到剪贴板,直接在MSN/QQ上粘贴即可.\" value='邀请好友投票' style='width:90px;' class='toupiao_btn' id=\"btn_InviteFriends_" + n.VotesId + "\" onclick=\"return InviteFriends('" + n.VotesId + "');\" /></td>";
tmpHtml += "</table>";
tmpHtml += "</li>";
tmpHtml += "<li class='ad_con' id='li_VotesContent_" + n.VotesId + "'>广告语创意说明:<span class=\"huise\" style=color:#909090;>" + n.VotesContent + "</span></li>";
});
tmpHtml += "</ul>";
$("#divVotesList").html(tmpHtml);
}
可能是编码问题,IE6解析是乱码。