Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:40:43+00:00 2026-05-23T07:40:43+00:00

I am new to javascript and have some data stored in a txt file

  • 0

I am new to javascript and have some data stored in a txt file that I want to use on my webpage.

However when I send an XmlHttpRequest to get the text file firefox throws a syntax error on the first line of the .txt I am trying to read in.

Here is my code:

    var txtFile = new XMLHttpRequest();

    txtFile.onreadystatechange = function() {

        if (txtFile.readyState === 4) {  

                if (txtFile.status === 200) {               
                    allText = txtFile.responseText;
                    lines = txtFile.responseText.split("\n"); 
            }
        }
    }
    txtFile.open("GET", "File:\\\myinfo.txt", true);    
    txtFile.send(null); 

Here is what the error message from firefox reads:

syntax error:
“File:\\myinfo.txt” Line:1

then down here it has the text that is on this line

I think it may mean that I’m not allowed to access a local file and this is firefox’s way of letting me know this.

Does anyone have any experience with this error or know what it means?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:40:44+00:00Added an answer on May 23, 2026 at 7:40 am

    The backslash character has special meaning in a string. It signifies that the next character is special in some way, for example you can include a quote inside a string by using the backslash to escape it:

    'It\'s a string'
    

    In order to include a literal backslash, you put it twice:

    'This is one backslash \\ character'
    

    So, in your example, you have \\\m. The first two slashes become one slash, and the \m is unrecognised as a valid escape sequence and so you get the error.

    Change your URL to either use forward slashes (which don’t have this special meaning and is the correct type of slash to use in a URL anyway), or double-up your backslashes:

    "file:///myinfo.txt"
    "file:\\\\\\myinfo.txt"
    

    Also, note that this URL doesn’t actually point to anything, it should be something like this:

    "file:///C:/myinfo.txt"
    

    Also, as pointed out above, XMLHttpRequest only works against the same domain as the page it’s on is hosted, so if your page is on http://www.example.com/ you can only access resources on http://www.example.com/.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that dynamically creates a new button through JavaScript that when
I have an ASP.NET user control that I want to write some dynamic Javascript
i have a javascript method that takes a date: convert(new Date(02/20/2010); how can i
I want it to have a popup dialog javascript box. Instead of a new
I have some Javascript that dynamically adds rows/fields when you click the button, Add
I have some Javascript code that acts on an pixel array defined like so:
I'm quite new to javascript but have undertaken a task to get better aquainted
I have opened a new window with JavaScript: var newwin = window.open('','preview','width=600,height=500'); Now I
I have used Javascript onlaod like this: function check() { var pic = new
I have just started learning Jquery and am new to writing javascript (I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.