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

  • Home
  • SEARCH
  • 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

Wondering how to open many new windows with Javascript. I have found plenty of
Being fairly new to JavaScript, I'm unable to discern when to use each of
Is there a way to spawn a new window via javascript in IE7 that
jQuery and JavaScript in general are new ground for me. What are some good
I just have a question about how to achieve DRY with javascript that generates
So I have found this code here This basically lets me pull some data
New to javascript/jquery and having a hard time with using this or $(this) to
I'm relatively new to Javascript and was wondering if there's a quick way to
I've been using PHP for too long, but I'm new to JavaScript integration in
Is it possible to launch a new window in JavaScript using the window.Open function,

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.