0

I have been struggling with this all day.

My jTable app works fine. It does the queries in the database and puts them in a table. The JSON that jTable receiving is like this.

{
  "Result": "OK",
  "Records": {
    "3": {
        "id": "518",
        "tableUID": "",
        "user_id": "1795",
        "username": "pnk"
    },
    "1": {
        "id": "517",
        "tableUID": "",
        "user_id": "1795",
        "username": "plk"
    },
    "2": {
        "id": "516",
        "tableUID": "",
        "user_id": "1797",
        "username": "d9"
    },
    "3": {
        "id": "515",
        "tableUID": "",
        "user_id": "1795",
        "username": "plkr"
    },
    "extra info": "some data that was generated by php and mysql"
  }
}

Is the JSON stored in a variable in jQuery? If so how can I access this variable?

Basically my question is: How do I get the extra info bit out of the JSON with Javascript?

αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
  • possible duplicate of [Accessing JSON object keys having spaces](http://stackoverflow.com/questions/10311361/accessing-json-object-keys-having-spaces) – αƞjiβ Nov 17 '14 at 16:00

1 Answers1

0

Have you tried this

// assuming above JSON string is stored in 'data' variable
var json = JSON.parse(data); 
alert(json.extra_info); //avoid space in variable name
//or
alert(json\[extra info\]); 

See here

Community
  • 1
  • 1
αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
  • Thanks Anjibman, this might work. so the json is stored in the 'data' variable? Ill try it with the jtable recordsloaded option. – user2756794 Nov 17 '14 at 16:03