Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Read text file in vanilla JS

function readTextFile(file)
{
    var rawFile = new XMLHttpRequest();
    rawFile.open("GET", file, false);
    rawFile.onreadystatechange = function ()
    {
        if(rawFile.readyState === 4)
        {
            if(rawFile.status === 200 || rawFile.status == 0)
            {
                var allText = rawFile.responseText;
                alert(allText);
            }
        }
    }
    rawFile.send(null);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: postman test check response status 
Javascript :: how to get json data from json file in node js 
Javascript :: indexof vs findindex 
Javascript :: ... unicode 
Javascript :: electron main.js template 
Javascript :: export aab react native 
Javascript :: nodejs express hot reload 
Javascript :: js json to object 
Javascript :: convert base64 to image nodejs 
Javascript :: check date format javascript 
Javascript :: vue shorthand 
Javascript :: if jsp 
Javascript :: jquery ready 
Javascript :: nodejs download image from url 
Javascript :: javascript sum array of objects by key 
Javascript :: How to get tailwindcss intellisense to work with react files 
Javascript :: javascript merge two objects 
Javascript :: react navigation navigator types 
Javascript :: How to calc() height in react native for styling 
Javascript :: hex to rgba in js 
Javascript :: Check ratelimit discord js 
Javascript :: jquery migrate 
Javascript :: add item to list javascript 
Javascript :: svelte ondestroy 
Javascript :: jquery on ready 
Javascript :: replace line break with html line break js 
Javascript :: union of two objects javascript 
Javascript :: js display 2d array 
Javascript :: js number with four decimal places 
Javascript :: javascript get elements that exist in two arrays 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =