0

Very simple question that's been dogging me. I have a handler that returns the following formatted JSON (and it has tested as valid):

[
{
"Field1": 1234,
"Field2": "My Name",
"Field3": 321,
"Field4": 456,
"Field5": 789,
"Field6": "Home",
"Field7": "123 Main St",
"Field8": "Updated 10/15/14",
"Field9": null,
"Field10": null
}
]

When I try to grab a value from this via:

var json = $.parseJSON(data);
var test = data.Field1;

I get 'undefined' for every value I test. The datatype on the ajax call is 'text' and 'data' in the above context represents the JSON object shown above.

Andrew
  • 253
  • 2
  • 14

1 Answers1

4

your JSON string is array not object, so after parsing it, you need to access items like array.

data[0].Field1
Omidam81
  • 1,887
  • 12
  • 20