Home > Net >  Using layui upload excel documents, reception to excel automatically converted into json, my questio
Using layui upload excel documents, reception to excel automatically converted into json, my questio

Time:10-04


Background: use layui desk upload excel document, the excel automatically converts json (has been achieved by the following code)
Question: my question is to convert the json through $. Ajax () submitted to the background, how to implement (pay attention to the content of the red, as the original application note), $. Ajax () code which should be under
The
!The code download address: https://fly.layui.com/extend/excel/


Thank you for the first,




The function uploadExcel (files) {
Try {
Excel. ImportExcel (files, {
//read the data at the same time combing data
Fields: {
'id' : 'A'
And 'username', 'B'
'experience', 'C'
'sex', 'D'
, 'score' : 'E'
'F', 'city'.
, 'classify' : 'G'
'H', 'wealth'.
'I', 'sign'.
}
{} function (data)
//data can also be combed

/*
Data=https://bbs.csdn.net/topics/excel.filterImportData (data, {
'id' : 'A'
And 'username', 'B'
'experience', 'C'
'sex', 'D'
, 'score' : 'E'
'F', 'city'.
, 'classify' : 'G'
'H', 'wealth'.
'I', 'sign'.
}



);
*/





//if you don't need to upload, can again $. Ajax () will be JSON data via JSON. Stringify () after processing can be passed to the backend
Layer. The open ({
Title: 'file conversion results'
, area: [' 799 px ', '399 px]
, tipsMore: true
, the content: laytpl ($(' # LAY - excel - export - ans). The HTML ()). The render ({data: data, files, files})
Success: the function () {
Element. Render (' TAB ');
Layui. Code ({



});
}
});
});
} the catch (e) {
Layer. Alert (e.m essage);
}
};



CodePudding user response:

 
$. Ajax ({
Url: "'
Data: JSON. Stringify (data),//have you got the JSON array
Type:
DataType: "'
Success: the function (data)
{},
Error: function (data)
{}
})

CodePudding user response:

Recommend to use the fileupload component,

CodePudding user response:

reference 1st floor Dear200892 response:
 
$. Ajax ({
Url: "'
Data: JSON. Stringify (data),//have you got the JSON array
Type:
DataType: "'
Success: the function (data)
{},
Error: function (data)
{}
})
thank a friend for advice, but I should add this code you provide where does provide code to me, I'm a beginner

CodePudding user response:

reference 3 floor of red reply:
Quote: refer to 1st floor Dear200892 response:

 
$. Ajax ({
Url: "'
Data: JSON. Stringify (data),//have you got the JSON array
Type:
DataType: "'
Success: the function (data)
{},
Error: function (data)
{}
})
thank a friend for advice, but I should add this code you provide where does provide code to me, I am beginner



You submit event
  • Related