1
버튼이 하나 있는데 버튼을 클릭하면이 파일의 내용이 표에 나열됩니다. 어떤 방법으로 나에게이 일을 할 수있는 아이디어를 줄 수 있습니까? TIA표에 데이터를 나열하는 방법
버튼이 하나 있는데 버튼을 클릭하면이 파일의 내용이 표에 나열됩니다. 어떤 방법으로 나에게이 일을 할 수있는 아이디어를 줄 수 있습니까? TIA표에 데이터를 나열하는 방법
var tableContent = '';
$.get('file path', function(data) {
//this will split the string into array line by line
var lineByline = data.split('\n');
//here we're itraing the array which you've created and printing the values
$.each(lineByline , function(key,value){
tableContent += '<tr>';
tableContent += '<td>' + value + '</td>';
tableContent += '</tr>';
});
$('#listHere').html(tableContent);
});
확인이 코드,
<table id="listHere">
</table>
당신은 로컬 시스템에서 파일을 액세스 할 수 없습니다. 텍스트 파일을 서버에 놓습니다.
var txtData = new Array();
$.get('passwords.txt', function (data) {
txtData = data.split('\n');
var htmTable = "";
for (var i = 0; i < txtData.length; i++) {
htmTable = htmTable + "<tr><td>" + txtData[i] + "</td></tr>";
}
$('#listHere').append(htmTable);
});
의
가능한 복제 [텍스트 파일에서 HTML 테이블에 데이터를로드하는 방법 (http://stackoverflow.com/questions/33006410/how-to-load-the-data-into-html- table-from-a-text-file) –
나를 계몽 해 주셔서 감사합니다. 어제 나는 그것을 찾을 수 없었습니다. 고마워요 @ SaravananSachi – Princess