主要是 formData 其他的没什么
var showTHArray = ['key','名称'];
function updateFileFun(obj){
if(jQuery("#edid").val()){
var formData = new FormData();
formData.append("fileMap", document.getElementById("attachFile").files[0]);
formData.append("edid", jQuery("#edid").val());
jQuery.ajax({
type: 'post',
url : 'IGOCRG0103_Upload.do',
data: formData,
cache: false,
processData: false,
contentType: false,
}).success(function (data) {
debugger;
if(data){
var obj = eval("("+data+")");
var jsonArray = obj.returnList;
var attrKey = obj.attrKey;
jQuery("#attkey").val(attrKey);
//创建表格
var dynamicTABLE = document.createElement("table");
//设置样式
dynamicTABLE.setAttribute("class", "table");
dynamicTABLE.setAttribute("id", "ocrgContrastTable");
dynamicTABLE.style.border = '1px solid #D8BFD8';
dynamicTABLE.style.borderCollapse = 'collapse';
//创建THEAD 标题行
var dynamicTHEAD = document.createElement("thead");
var dynamicTHEADTR = document.createElement("tr");
//循环标题行值,设置标题行
for (var i = 0; i < showTHArray.length; i++) {
var dynamicTH = document.createElement("th");
dynamicTH.setAttribute("class", "align-center");
dynamicTH.innerHTML = showTHArray[i];
dynamicTH.style.border = '1px solid #00BFFF';
dynamicTHEADTR.appendChild(dynamicTH);
}
dynamicTHEAD.appendChild(dynamicTHEADTR);
dynamicTABLE.appendChild(dynamicTHEAD);
//创建TBODY
var dynamicTBODY = document.createElement("tbody");
for (var i = 0; i < jsonArray.length; i++) {
var value = jsonArray[i];
//创建数据行TR
var dynamicTR = document.createElement("tr");
dynamicTR.setAttribute("rowindex", (i + 1));
var dynamicTD1 = document.createElement("td");
dynamicTD1.setAttribute("class", "align-center");
dynamicTD1.style.border = '1px solid #00BFFF';
dynamicTD1.innerHTML = '<input readonly="readonly" type="text" value="'+value+'" name="ocrgKey" >';
dynamicTR.appendChild(dynamicTD1);
var dynamicTD2 = document.createElement("td");
dynamicTD2.setAttribute("class", "align-center");
dynamicTD2.style.border = '1px solid #00BFFF';
dynamicTD2.innerHTML = "<input type='text' name='ocrgValue'>";
dynamicTR.appendChild(dynamicTD2);
dynamicTBODY.appendChild(dynamicTR);
}
dynamicTABLE.appendChild(dynamicTBODY);
jQuery("#ocrgContrastDiv").append(dynamicTABLE);
}
}).error(function () {
alert("上传失败");
});
}else{
Layer.alert("统计不能为空!");
jQuery("#attachFile").val("");
}
}