cshmicky
cshmicky
2017-01-10 19:58

swiper怎么动态加载数据?

  • 数据
  • json

$.ajax({ url: "../Minitor/data_SOE.ashx?Action=GetSOEByPage", type: "GET", dataType: "json", data: { page: page, treeid: 1, rows: 10, endtime: endtime, starttime: '2016-07-20 00:00:00' }, cache: false, success: function (data) { var data = eval(data); var num = data.ResultData.DataTable.length; var total = data.ResultData.totalRecords; var max = Math.floor(10 / 10); var mySwiper = new Swiper('.swiper-container', { onSlideNextStart: function (swiper) { $.ajax({ url: "../Minitor/data_SOE.ashx?Action=GetSOEByPage", type: "GET", dataType: "json", data: { page: 1, treeid: 1, rows: 10, endtime: endtime, starttime: '2016-07-20 00:00:00' }, cache: false, success: function (data) { var data = eval(data); var mySwiper = new Swiper('.swiper-container', { }); var html = ""; for (var i = 0; i < 10; i++) { html += data.ResultData.DataTable[i].TagName; if ((i + 1) % 10 == 0) { mySwiper.appendSlide('
' + 'html' + '
'); //加到Swiper的最后 $(".swiper-slide").addClass('container jin1'); mySwiper.update(); } }; // $(".swiper-container").find('.swiper-wrapper').html(s); }, error: function (data) { alert("未查明原因"); } }); } }); var html = ""; for (var j = 0; j < 10; j++) { var time = new Date(eval('new ' + (data.ResultData.DataTable[j].CreateTime.replace(/\//g, '')))).Format('yyyy-MM-dd hh:mm:ss'); html += "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + '' + "" + "" + "
" + "" + data.ResultData.DataTable[j].IEDNO + "" + " " + "" + "" + "" + "" + "" + "
" + "安装位置:" + " " + data.ResultData.DataTable[j].StationName + data.ResultData.DataTable[j].MainLineName + data.ResultData.DataTable[j].TwoerAdr + "
" + data.ResultData.DataTable[j].TagName + " ' + time + '
"; $(".table tbody tr td").find("i").addClass("icon iconfont"); $(".table tbody tr td a i").css({ "color": "#337ab7" }); $(".icon ").css({ "text-align": "right" }); if ((j + 1) % 10 == 0) { mySwiper.appendSlide('
' + html + '
'); //加到Swiper的最后 $(".swiper-slide").addClass('container jin1'); html = ""; } }; // $(".swiper-container").find('.swiper-wrapper').html(); }, error: function (data) { alert("未查明原因"); } });

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答