2016-10-14 3 views
-2

오류가 발생합니다. console.log은 기능이 아니지만 이전에는 문제가되지 않았습니다. 오류는 첫 번째 및 두 번째 console.log에서 발생하며 그 곳을지나갑니다.console.log가 javascript의 함수 오류가 아닙니다.

세미콜론이있어서 문제가 무엇인지 정확히 알 수 없습니까?

document.getElementById("fileToRead").addEventListener("change",function(event) { 
var input = document.getElementById("fileToRead"); 
//Variable for if statement to see if there is a header in the file. 
var headerType = false; 
console.log(input); 
input = event.target.files[0]; 

console.log('test'); 

    for(var i = 0; i < input.files.length; i++){ 
     var files = input.files[i]; 
      Papa.parse(files, { 
      header:headerType, 
      dynamictyping:true, 
      complete:function(results){ 
       console.log(results); 
       var input = results.data; 
       if(headerType === false){ 
        input.forEach(function(input){ 
         jsonData.theData = theData; 

         var singleEntry = { 
          "symbol" : input[0], 
          "date"  : input[1], 
          "open"  : input[2], 
          "high"  : input[3], 
          "low"  : input[4], 
          "close"  : input[5], 
          "volume" : input[6] 
          }; 

         jsonData.theData.push(singleEntry); 
         return jsonData; 
        }); // End forEach loop 
       } else { 

       } // End if statement for headerType 
       document.getElementById("editor").innerHTML = JSON.stringify(jsonData.theData); 
       } // End Callback Complete 

      }); // End PapaParse 
    } // End for loop 
}); 

가 난 코드가 그래서 이것은 최종 결과입니다 주석하고 여전히 console.log 함수 아니라고 말한다!

// This is for the views/admin.ejs file only 
//This file describes how the Admin page works, hiding divs and working with  the data 
// importing 


var jsonData = {}; 
var theData = []; 

document.getElementById("fileToRead").addEventListener("change",function(event) { 
// var input = document.getElementById("fileToRead") 
// //Variable for if statement to see if there is a header in the file. 
// var headerType = false; 

// input = event.target.files[0]; 

console.log('test'); 

    // for(var i = 0; i < input.files.length; i++){ 
    //  var files = input.files[i]; 
    //   Papa.parse(files, { 
    //   header:headerType, 
    //   dynamictyping:true, 
    //   complete:function(results){ 
    //    console.log(results); 
    //    var input = results.data; 
    //    if(headerType === false){ 
    //     input.forEach(function(input){ 
    //      jsonData.theData = theData; 

    //      var singleEntry = { 
    //       "symbol" : input[0], 
    //       "date"  : input[1], 
    //       "open"  : input[2], 
    //       "high"  : input[3], 
    //       "low"  : input[4], 
    //       "close"  : input[5], 
    //       "volume" : input[6] 
    //       }; 

    //      jsonData.theData.push(singleEntry); 
    //      return jsonData; 
    //     }); // End forEach loop 
    //    } else { 

    //    } // End if statement for headerType 
    //    document.getElementById("editor").innerHTML = JSON.stringify(jsonData.theData); 
    //    } // End Callback Complete 

    //   }); // End PapaParse 
    // } // End for loop 
}); 
+0

이 코드를 어떻게 실행하고 있습니까? 브라우저에서 어떤 브라우저/버전입니까? – Amy

+0

크롬 53.0.2785.143 – illcrx

+0

이 코드 블록은 오류의 원인입니까? – Dummy

답변

0

코드가 더 내려간 기능으로 콘솔을 다시 정의했습니다. 초보자 실수를 완전히 끝내고 ...... 다시 한 번 실수를 저 지르지 마십시오.

관련 문제