龙空技术网

js上传word文档并写入数据库

孤帆月下 231

前言:

今天我们对“ajaxhtmldatatype”大致比较珍视,看官们都需要学习一些“ajaxhtmldatatype”的相关内容。那么小编也在网络上汇集了一些有关“ajaxhtmldatatype””的相关内容,希望看官们能喜欢,各位老铁们一起来学习一下吧!

视频加载中...

function uploadflie(){

let filename;

let objFile = document.getElementById('uploadfile');

filename = objFile.files[0];

determine(filename);

}

function determine(){

let content = Array.prototype.shift.apply(arguments);

console.log(content);

let contentname = content.name;

let suffix = contentname.substring(contentname.lastIndexOf('.'));

if(suffix == '.docx'){

postajx(content);

}else{

console.log('123');

}

}

function postajx(){

let fliepath = Array.prototype.shift.apply(arguments);

let data = new FormData();

data.append('number',fliepath);

$.ajax({

type:'POST',

url:';,

dataType: "json",

data: data,

processData: false,

contentType: false,

success: function () {

alert('提交成功');

views()

location.reload();

}

})

}

function views(){

let ajx = new XMLHttpRequest();

let url = ';;

ajx.open('GET',url,true);

ajx.onreadystatechange = function(){

if(ajx.readyState == 4){

if(ajx.status == 200){

alert('上传成功')

}

}

}

ajx.send();

}

function overallsituation(){

let ajx = new XMLHttpRequest();

let url = ';;

ajx.open('GET',url,true);

ajx.onreadystatechange = function(){

if(ajx.readyState == 4){

if(ajx.status == 200){ alltable(JSON.parse(ajx.responseText)['data']) document.getElementById('table01').addEventListener('click',function(e){

querytable(e.target.id);

deletdata()

})

}

}

}

ajx.send();

}

overallsituation()

function alltable(){

let content = Array.prototype.shift.apply(arguments);

let arr = ['序号','名称','内容','操作'];

let div01 = document.getElementById('div01');let table = document.createElement('table');

let tr = document.createElement('tr');

div01.appendChild(table);

table.id = 'table01';

table.appendChild(tr);

table.border = '2px';

div01.style.margin = 'auto';

table.style.margin = 'auto';

table.style.textAlign = 'center';

for(let i = 0;i<arr.length;i++){

let th = document.createElement('th');

tr.appendChild(th);

th.innerHTML = arr[i];

}

for(let i=0;i<content.length;i++){

let tr1 = document.createElement('tr');

let td = document.createElement('td');

let td1 = document.createElement('td');

let td2 = document.createElement('td');

let td3 = document.createElement('td');

table.appendChild(tr1);

table.appendChild(td);

table.appendChild(td1);

table.appendChild(td2);

table.appendChild(td3);

td.innerHTML = i+1;

td1.innerHTML = content[i]['name'];

td2.innerHTML = content[i]['text'];

td3.innerHTML = '查询';

td3.style.background = 'blue';

td3.id = content[i]['id'];

}

}

function querytable(){

let content = Array.prototype.shift.apply(arguments);

console.log(content)

data = {

'num':content

}

let ajx = new XMLHttpRequest();

let url = ';

ajx.open('POST',url,true);

ajx.onreadystatechange = function(){

if(ajx.readyState == 4){

if(ajx.status == 200){

show(JSON.parse(ajx.responseText)['data'])

}

}

}

ajx.send(JSON.stringify(data));

}

function show(){

let content = Array.prototype.shift.apply(arguments);

let div01 = document.createElement('div');

div01.id = 'div_div';

let p = document.createElement('p');

let p1 = document.createElement('p');

document.body.appendChild(div01);

div01.appendChild(p);

div01.appendChild(p1);

p.innerHTML = '名称:'+content[0]['name'];

p1.innerHTML = '内容:'+content[0]['text'];

}

function deletdata(){

let div_div = document.getElementById('div_div');

if(div_div){

div_div.remove();

}

}

标签: #ajaxhtmldatatype