上面的代码也没什么好精简的
也就下面的代码倒是可以这样写
function showResponse(data) {var opt = {
message: data.msg,
closable: false,
buttons: []
}
if (data.type == "succeed") {
opt.title = '提示'
opt.type = 'type-success'
opt.buttons.push({
label: '确定',
cssClass: 'btn-success',
action: closeFn
})
} else {
opt.title = '错误'
opt.type = 'type-danger'
opt.buttons.push({
label: '关闭',
cssClass: 'btn-danger',
action: closeFn
})
}
var dialog = new BootstrapDialog(opt)
dialog.realize()
dialog.open()
}
function closeFn() {
$.each(BootstrapDialog.dialogs, function (id, dialog) {
dialog && dialog.close()
})
}
for (var i = 0 i < ajax.length i++) {var row = ajax[i]
for (var j = 1 j < 16 j++) {
eval("d" + j + "+=" + parseFloat(row[j]))
}
}
totalData.push("<b>统计:</b>")
for (var i = 1 i < 16 i++) {
totalData.push(eval("d" + i))
}