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 8517445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:42:12+00:00 2026-06-11T05:42:12+00:00

Apologies in advance as I’m very new to javascript. Essentially, I cobbled together 2

  • 0

Apologies in advance as I’m very new to javascript. Essentially, I cobbled together 2 scripts and which I’m trying to get to work. I know that javascript can’t normally access local files but with the File object it may be possible?

In the code below, if my selected file is a CSV, how can I pass it to the next function $.get('data.csv', function(data) so 'data.csv' is actually the file selected?

<html>
<script type="text/javascript">

    document.getElementById('file').addEventListener('change', handleFileSelection, false);

    function handleFileSelection(evt) {
      console.log(evt);
      var f = evt.target.files[0];   
    }

    $(document).ready(function() {

      $.get('data.csv', function(data) {
        // Split the lines
        var lines = data.split('\n');

        //more code

      });

    });
</script>

<body>
    <input type="file" id="file" name="file" />
    <output id="list"></output>
</body>

</html>

​

  • 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-06-11T05:42:14+00:00Added an answer on June 11, 2026 at 5:42 am

    The first problem what I see here is that you are trying to add event listener earlier than the actual element is created (as RobG said).

    And the second problem that I can mention is that you’re trying to use $.get to parse that local CSV file. If you are using jQuery, then $.get makes a GET asynchronous request to some URL and it is not what you need. You have to investigate FileReader object. I am not familiar with it, so I can’t bring an example of working code, but you can look for some examples here.

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

Sidebar

Related Questions

I'm pretty new to Node.js, so apologies in advance if I don't know what
Gentlepeeps, I'm new with Jquery. Apologies in advance for the basic question. I'm trying
I'm fairly new to Python, so my apologies in advance if this is much
This, I'm sure is a pretty basic question about JavaScript, so apologies in advance.
Apologies in advance if this is a silly question, am very much a beginner.
Apologies in advance but I have never seen this error before and don't know
I'm new to Django, so apologies in advance if this is a rookie issue.
Apologies in advance, am fairly new to rails. Creating a site to showcase cooking
This is a very wide-ranging/vague question, but here goes. Apologies in advance. The app
Apologies in advance for the simplicity of this question. I am trying to import

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.