코딩 관련/Javascript와 jQuery, JSON
[Javascritpt] 로컬 텍스트 파일 읽기
메리짱123
2021. 7. 26. 11:40
반응형
let content = null;
let xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "/static/file/파일이름", false);
xmlhttp.send();
//파일 로드 성공 시 파일에서 읽은 텍스트를 content에 담음
if (xmlhttp.status == 200) {
content = xmlhttp.responseText;
}
console.log(content);
반응형