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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:04:58+00:00 2026-06-18T01:04:58+00:00

I’m getting an unexpected identifier error with this line of code: var player[data[x].split(|,1)] =

  • 0

I’m getting an unexpected identifier error with this line of code: var player[data[x].split("|",1)] = data[x].split("|")[1];

The response data is in this format:

Mike Trout|0\nRyan Braun|0\n...

Here is the full JS function:

function updateChance(round, pickNumber)
{
    $.ajax({
            type: "GET",
            data: {round: round, pickNumber: pickNumber},
            url: "./lib/updatechance.php",
            dataType: "html",
            async: false,
            success: function(response) 
            {
                var data = response.split("\n");
                for (var x=0; data.length; x++)
                {
                    var player[data[x].split("|",1)] = data[x].split("|")[1];
                }

                for (var r = 1; r < $('#battersTable').rows.length; r++){
                    //do something with player

                }
            }
    });
}
  • 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-18T01:04:59+00:00Added an answer on June 18, 2026 at 1:04 am

    Look what you did here

    .split("|",1)  //wrong
    

    and

    .split("|")[1]  //right
    

    another issue, you have var with the bracket notation, not going to happen.

    var player[data[x].split("|",1)]  <-- var, should not be there
    

    And the for loop is missing a check so that is going to run infinite.

    for (var x=0; data.length; x++)  <-- data.length what?
    

    Why are you splitting twice? Twice the effort, do it once

    for (var x=0; x<data.length; x++) {
        var info = data[x].split("|");
        player[info[0]] = info[1];
    }
    

    If player is not defined globally, you will need to define it before the loop.

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

Sidebar

Related Questions

I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am using jsonparser to parse data and images obtained from json response. When
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.