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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:41:18+00:00 2026-06-04T11:41:18+00:00

I have a php program where I just test some sample data. I am

  • 0

I have a php program where I just test some sample data. I am getting error as missing ] after element list. How can I read this?

$dataDetailsList = array();
array_push($dataDetailsList, array('a' =>'1','b' =>'2','c' =>'3','d' =>'4','e' =>'5'));
echo json_encode(array("DataDetailsList"=>$dataDetailsList));

Then in my jQuery processor I am doing like this.

function requestData() {
    $.ajax({
        url: 'live-server-data.php',
        success: function(data) {
            //alert(json);
            var jsonData = eval(" (" + data + ") ");
        },
        cache: false
    });
  • 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-04T11:41:20+00:00Added an answer on June 4, 2026 at 11:41 am

    Don’t use eval is evil.
    Instead of this use:

    JSON.parse(data); // not supported in IE7 and below
    

    I think you need to try

    dataType: 'json'
    

    That is,

    $.ajax({
        url: 'live-server-data.php',
        dataType: 'json',
        success: function(data) {
            var jsonData = data;
            console.log(jsonData);
            $.each(jsonData.DataDetailsList, function(key, val) {
                 var key = Object.keys(val)[0],
                     value = val[key];
                 console.log(key); // output: a, b, c ...
                 console.log(value); // output: 1, 2, 3,...
                // alternative
                for(var key in val) {
                    console.log(key);
                    console.log(val[key]);
                }
            });
        },
        cache: false
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that returns a comma-separated string of numbers after doing some
Just installed a nginx server with ubuntu 11.04 and after loading my php program
I have a PHP program that has been written keeping in mind a single
I have a SQL update statement I am running from inside a PHP program.
I have PHP code which connects to MySql and encodes data to JSON. Later
I have a PHP program that has the user copying a URI into a
This is incredibly strange and I can't figure it out. When using https://localhost/program/admin/menu.php I
i have link php program - its activation link as activation.php?user=jack?hash=abcd?id=20 When i use
I have a PHP script that runs as a CGI program and the HTTP
I have a list, consisting of links looking like this: <a href=index.php?p=page_1>Page 1</a> <a

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.