62,270
社区成员
发帖
与我相关
我的任务
分享
function importData() {
var strID="";
$("input[type='checkbox']:checkbox").each(function(){
if($(this).attr("checked")){
strID += $(this).val() + ","
}
})
if (strID == "") {
alert("请选择需要导入的文件");
}
else {
if (confirm("确定要导入当前选择的文件吗?")) {
$("input[type='checkbox']:checkbox").each(function () {
if ($(this).attr("checked")) {
var configID = $(this).val();
importProce(configID);
}
})
}
}
}
function importProce(configID) {
$.ajax({
type: "POST",
async:true,
contentType: "application/json; charset=utf-8",
url: "/Clearing/Import",
dataType: "json",
data: JSON.stringify({ configID: configID }),
beforeSend: function (XMLHttpRequest) {
$("#indicator"+configID).show();
},
success: function (data) {
alert("导入成功");
},
complete: function (XMLHttpRequest, textStatus) {
$("#indicator"+configID).hide();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
}
//定义全局变量
var arr = new Array();
$("input[type='checkbox']:checkbox").each(function () {
if ($(this).attr("checked")) {
var configID = $(this).val();
//这里赋值
arr.push(configID);
}
});
//开始调用
importProce() ;
function importProce() {
if(arr.length>0){
$.ajax({
type: "POST",
async:true,
contentType: "application/json; charset=utf-8",
url: "/Clearing/Import",
dataType: "json",
data: JSON.stringify({ configID: arr[0]}),//获取第一个Id
beforeSend: function (XMLHttpRequest) {
$("#indicator"+configID).show();
},
success: function (data) {
alert("导入成功");
arr.shift();//成功以后移除第一个Id
importProce();//递归
},
complete: function (XMLHttpRequest, textStatus) {
$("#indicator"+configID).hide();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
}
}