I am trying to read from a file on the local machine using Ajax.The file it is reading from is a text file having numbers like 1 2 3 4 5 but when I run the code in a browser in spite of all the formatting the numbers appear separated by a space rather then on new lines.If someone could tell me how to get the numbers printed out in the format that they originally exist,I would be thankful
Here is the code:
<html>
<script>
var oRequest;
var i;
if(document.all) {
oRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
else {
oRequest = new XMLHttpRequest();
}
oRequest.open("GET", "file:///C:/testing.txt", false);
oRequest.send(null);
textToBeWritten = oRequest.responseText;
document.write(textToBeWritten+"<br />");
</script>
</html>