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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:46:47+00:00 2026-05-27T00:46:47+00:00

Here is my relevant jQuery code: $.get(‘sampleData.csv’, function(data) { var lines = data.split(‘\r\n’); The

  • 0

Here is my relevant jQuery code:

$.get('sampleData.csv', function(data) {
    var lines = data.split('\r\n');

The first few line of the sampleData.csv file look like this:

2009,0,2,29.0000
2009,0,6,655.6200

I get 2 errors.
On the first line of csv file I get the error

syntax error

On the 2nd line of code I get the error

data.split is not a function

What am I doing wrong?

ETA According to the firebug console, the responseText is the following:

2009,0,2,29.0000\r\n2009,…\r\n2011,10,30,494.3500\r\n

ETA I added an alert of the data before I try splitting it into lines, and I get the following:

[Object XMLDocument]

  • 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-27T00:46:48+00:00Added an answer on May 27, 2026 at 12:46 am

    I believe you misunderstand what jQuery.get() is suppose to be used for.

    From it’s doc page, "...Load data from the server using a HTTP GET request...."

    Doing a $.get() on a file will not get you that file’s data into a structure that can be used. You have to request this through a server which will then provide the .csv data … it should look something like the following

    $.get('http://url.to.server.page',function(data){
        var dataStr = new String(data);
        var lines = dataStr.split('\n');
    });
    

    EDIT::
    Since you say the data is being ‘loaded’ properly, try this fiddle. It works just fine.


    EDIT2::

    Your last edit gave some interesting insight. When it pulls the .csv file, its converting it to a type of XML vs text. Try the following:

    $.get('http://url.to.server.page',function(data){
        var dataStr = new String(data);
        var lines = dataStr.split('\n');
    },dataType='text');
    

    This should put the returning ‘data’ into the proper string format.

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

Sidebar

Related Questions

I'm having some trouble with the jQuery hover method. Here's the relevant JavaScript code:
I have this code: var myRSS =[]; function rssReader() { $.getJSON('bbc.php', function(data){ console.log(data); $.each(data[0].channel.item,
Here's the relevant code snippet. public static Territory[] assignTerri (Territory[] board, String[] colors) {
Here's the relevant code: public static void printBoarders (Territory x) { int t =
Here's the relevant bit of the source code: class Dice { String name ;
I have the following jQuery code: $.ajax({ type: POST, url: /search, data: $(form).serialize(), success:
I have a strange problem with mod_rewrite, the rules that are relevant here are:
I do not seem to understand how to catch constructor exception. Here is relevant
Here are the relevant models: User Product Order A User can sell or buy
Here's the relevant part of the Dice class: import java.util.*; class Dice { String

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.