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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:04:08+00:00 2026-06-01T14:04:08+00:00

I started a demonstration project on HTML, JSON and jQuery recently. Thing I want

  • 0

I started a demonstration project on HTML, JSON and jQuery recently.
Thing I want to achieve now is get data from the JSON file and load it into my table.
I am new to JSON so it took me a day to get to nothing, the data was not loaded into my table.

Here is my JSON file, ‘contact.json’:

{
    "length": 2,
    "info": [
        {
            "fullname":"Noob Here",
            "email":"myemail@server.com",
            "phone":"123456",
            "badgeid": "11111",
        },
        {
            "fullname":"Newbie There",
            "email":"hisemail@server.com",
            "phone":"589433",
            "badgeid": "11112",
        }
    ]
}

My script to load data:

window.onload = function () {
    var contacts;
    setTimeout(loadData(contacts, "contact"), 2000);
    $(contacts.info).each(function(index, element){  
        $('#contacts').append('<tr><td>' + element.fullname + '</td><td>'
            + element.email + '</td><td>'
            + element.phone + '</td><td>'
            + element.badgeid + '</td></tr>');       
    })
};

function loadData(myobject, myfile){
    myobject = $.parseJSON("../data/" + myfile + ".json");
};

Please notice that I may want to load from various JSON file, so loadData have some agruments there. Otherwise, it will parse JSON file directly.

I already had a ‘#contact’ table declared in HTML.
The error console said:

Uncaught SyntaxError: Unexpected token.
jQuery.extend.parseJSONjquery.min.js:442
loadDataHomepage.html:23
window.onload

Why is this error appearing? How do I fix this problem?

  • 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-01T14:04:09+00:00Added an answer on June 1, 2026 at 2:04 pm

    Run your JSON through a JSON validator, for instance JSONLint.com. You have a syntax error in your JSON:

    {
        "length": 2,
        "info": [
            {
                "fullname":"Noob Here",
                "email":"myemail@server.com",
                "phone":"123456",
                "badgeid": "11111",  <---- Do not put a comma before a curly brace
            },
            {
                "fullname":"Newbie There",
                "email":"hisemail@server.com",
                "phone":"589433",
                "badgeid": "11112",  <---- remove comma before curly brace
            }
        ]
    }
    

    Your JSON should instead look like this:

    {
        "length": 2,
        "info": [
            {
                "fullname":"Noob Here",
                "email":"myemail@server.com",
                "phone":"123456",
                "badgeid": "11111"
            },
            {
                "fullname":"Newbie There",
                "email":"hisemail@server.com",
                "phone":"589433",
                "badgeid": "11112"
            }
        ]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started a Rails project recently and decided to use RESTful controllers. I created
Started learning octave recently. How do I generate a matrix from another matrix by
Started a webpage that now contains a lot of analytic data. Now that I
Started a new project from scratch, converted to JPA, my persistence provider is EclipseLink,
I started learning Jquery mobile, I followed this http://dev.jtsage.com/jQM-SimpleDialog/demos/string.html . Nothing happens when I
started a visual studio 2010 database project . however i am only able to
Started with a default Prism Shell project and all was working as expected. I
I have recently started using coffeescript with Rails and I am finding that sometimes
Started using omnifocus recently and really like it. I prefer gmail's web interface, so
Started researching Transfer ORM recently and find it pretty cool. Today I've noticed that

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.