Sm00rf9000 Sm00rf9000 - 9 months ago 49
Javascript Question

Get text value from .txt file

I have a script which gets a value from a .txt file, I have done it with a number value where it works perfectly, but when I want to do it with another .txt file, which is a text and not a number I get the "NaN" error which I know stands for "not a number", but then how do I change it to work so that I can get the value text in the .txt file?

My script.

<div class="displayNameCurrent">
Display name: <span id="displayNameDisplay"></span>

<script type="text/javascript">
var read = new XMLHttpRequest();'GET', 'displayNameFile.txt', false);

var displayName = parseInt(read.responseText)
document.getElementById("displayNameDisplay").innerHTML = displayName;


If you don't want to convert the text to an integer, simply don't run parseInt over it.