jQuery: read text file from file system

前端 未结 10 2516
再見小時候
再見小時候 2020-11-30 10:09

I am trying to read a text file using jquery, like this:

// LOAD file and split line by line and append divs
$.get(\'myFile.txt\', function(data) {    
    v         


        
10条回答
  •  情话喂你
    2020-11-30 10:42

    this one is working

            $.get('1.txt', function(data) {
                //var fileDom = $(data);
    
                var lines = data.split("\n");
    
                $.each(lines, function(n, elem) {
                    $('#myContainer').append('
    ' + elem + '
    '); }); });

提交回复
热议问题