87,909
社区成员
发帖
与我相关
我的任务
分享
兄弟对这个表进行增加删除修改需要二次更新列表而且我每次都清空了, alert($('#ttitle').html(' '));
alert($('#tbody').html(''));
<script src="../scripts/jquery-1.7.1.min.js"></script>
<script>
$(function () {
GetDataList();
GetDataList();
})
function GetDataList() {
alert($('#ttitle').html(' '));
alert($('#tbody').html(''));
$('#ttitle tr').remove();
$('#ttitle tr td').remove();
$('#tbody tr').remove();
$('#tbody tr td').remove();
$.post('getlist.ashx', {}, function (data) {
var mytitle = $('<tr></tr>');
//先添加首行列名
$.each(data[0], function (i, value) {
mytitle.append($('<td></td>').append(i));
})
$('#ttitle').append(mytitle);
$.each(data, function (i, value) {
var buff = $('<tr></tr>');
$.each(value, function (j, ivalue) {
if (j == 'addtime') {
$('<td></td>').append(ChangeDateFormat(ivalue)).appendTo(buff);
}
else {
$('<td></td>').append(ivalue).appendTo(buff);
}
})
$('#tbody').append(buff);
});
data = '';
}, 'json')
}
function ChangeDateFormat(cellval) {
var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var hours = date.getHours();
var mins = date.getMinutes();
var seco = date.getSeconds();
return date.getFullYear() + "-" + month + "-" + currentDate + ' / ' + hours + ':' + mins + ':' + seco;
}
</script>
</head>
<body>
<table id="mytitle" class="table">
<thead id="ttitle">
</thead>
<tbody id="tbody"></tbody>
</table>
</body>
这样还是不行啊
$(function () {
GetDataList();
GetDataList();
})
你这里调用两次,你不会粗来双份,那给你50份,你觉得合适么
你咋不这样玩呢
$(function () {
for(var i=0;i<Number.MAX_VALUE;i++){
GetDataList();
}
})
$(function () {
GetDataList();
/////////////////////////GetDataList();//调用一次就行了
})