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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:51:45+00:00 2026-06-08T19:51:45+00:00

In my javascript I have this json working just fine. { sEcho: 1, iTotalRecords:

  • 0

In my javascript I have this json working just fine.

{
    "sEcho": 1, 
    "iTotalRecords": 58, 
    "iTotalDisplayRecords": 58, 
    "aaData": [ 
        ["Gecko","Firefox 1.0","Win 98+ / OSX.2+","1.7","A"],
        ["Gecko","Firefox 1.5","Win 98+ / OSX.2+","1.8","A"],
        ["Gecko","Firefox 2.0","Win 98+ / OSX.2+","1.8","A"],
        ["Gecko","Firefox 3.0","Win 2k+ / OSX.3+","1.9","A"],
        ["Gecko","Camino 1.0","OSX.2+","1.8","A"],
        ["Gecko","Camino 1.5","OSX.3+","1.8","A"],
        ["Gecko","Netscape 7.2","Win 95+ / Mac OS 8.6-9.2","1.7","A"],
        ["Gecko","Netscape Browser 8","Win 98SE+","1.7","A"],
        ["Gecko","Netscape Navigator 9","Win 98+ / OSX.2+","1.8","A"],
        ["Gecko","Mozilla 1.0","Win 95+ / OSX.1+","1","A"]
    ] 
}

But this is of course hard coded and I want to make aaData dynamic . I am planning on doing something like $.ajax my php has this code

$result = mysql_query("SELECT * FROM Persons");

$newArray = array();
while($row =mysql_fetch_array($result) ){
    $newArray[] = $row;
}

echo json_encode($newArray);

and the data from json_endcode is

[
{"0":"1","P_Id":"1","1":"zamor","LastName":"zamor","2":"credit","FirstName":"credit","3":"Giftcard","Address":"Giftcard","4":"Finance","City":"Finance"},{"0":"3","P_Id":"3","1":"zamor3","LastName":"zamor3","2":"credit","FirstName":"credit","3":"Giftcard","Address":"Giftcard","4":"Finance","City":"Finance"},{"0":"4","P_Id":"4","1":"zamor4","LastName":"zamor4","2":"credit","FirstName":"credit","3":"Giftcard","Address":"Giftcard","4":"Finance","City":"Finance"},{"0":"5","P_Id":"5","1":"zamor5","LastName":"zamor5","2":"credit","FirstName":"credit","3":"Giftcard","Address":"Giftcard","4":"Finance","City":"Finance"},{"0":"2","P_Id":"2","1":"zamor2","LastName":"zamor2","2":"credit","FirstName":"credit","3":"Giftcard","Address":"Giftcard","4":"Finance","City":"Finance"}
]

notice that it has [{ …}] instead of [[…]]
so if I replace my aaData (hardcoded one, with this above) it goes me error. How can I make my php code to return something that is in aaData.
thanks

  • 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-08T19:51:46+00:00Added an answer on June 8, 2026 at 7:51 pm

    Because you providing associative array to list.

    php > $simple = array(1,2,3,4,5);
    php > $assoc = array('a'=> 1, 'b' => 2);
    php > echo json_encode($simple);
    [1,2,3,4,5]
    php > echo json_encode($assoc);
    {"a":1,"b":2}
    

    try to replace with

    $newArray[] = array_values($row);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to parse JSON in JavaScript I have this JSON string: [{title:
I have no idea how to properly 'return' this JSON object (in JavaScript): function
I am trying to learn javascript i have this code: x=x.replace(/^\s+|\s+$/g,); can i have
I'm totally beginner in java. In javascript i have this regex: /[^0-9.,\-\ ]/gi How
I have this Javascript/JQuery code: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script> <script type=text/javascript> name = $(#name).val(); alert(Name:
I have this Javascript function that sends username and password to php file through
I have this Javascript: <script language=javascript type=text/javascript> $().ready(function() { $('#ex2').jqm({ajax: 'view.php?id=<?=$objResult[id];?>', trigger: 'a.ex2trigger'}); });
I have this Javascript code I inherited from another developer. I am very new
i have this javascript code to which i want to add the jquery fade-in
I have this javascript code below that uses jquery, it is suppoed to be

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.