I'd like to do a very simple AJAX request for some JSON data and then parse it. The code I am using is as follows:
$.get('/ajax/search/DSB.json', function (data) {
searchData=$.parseJSON(data);
});
I am getting an error: "unexpected token o." I have verified that the file in question is valid JSON. I have also Googled the answer - everyone with this problem is passing a javascript object to the JSON parser, which is obviously redundant. However, I'm not sure what the problem is in this case. Thoughts?
Here's the JSON, so you can check for yourselves if it's valid (it is).
{
"numCols": 2,
"colNames": [
"Disability Level",
"Region"
],
"colWidths": [
200,
null
],
"colFilters": [
[
"",
"All Disability Types",
"Not Significantly Disabled",
"Significantly Disabled"
],
[
"",
"All Regions",
"East Region",
"North Central Region",
"South Central Region",
"West Region"
]
],
"table": [
[
"Significantly Disabled",
"North Central Region",
1000013
],
[
"Not Significantly Disabled",
"All Regions",
1000006
],
[
"Significantly Disabled",
"All Regions",
1000011
],
[
"Significantly Disabled",
"West Region",
1000012
],
[
"All Disability Level",
"West Region",
1000002
],
[
"All Disability Level",
"South Central Region",
1000004
],
[
"Not Significantly Disabled",
"South Central Region",
1000009
],
[
"All Disability Level",
"All Regions",
1000001
],
[
"Not Significantly Disabled",
"West Region",
1000007
],
[
"Significantly Disabled",
"East Region",
1000015
],
[
"Not Significantly Disabled",
"East Region",
1000010
],
[
"All Disability Level",
"East Region",
1000005
],
[
"Significantly Disabled",
"South Central Region",
1000014
],
[
"All Disability Level",
"North Central Region",
1000003
],
[
"Not Significantly Disabled",
"North Central Region",
1000008
]
],
"names": [
[
1000013,
"Significantly Disabled Participants in North Central Region"
],
[
1000006,
"Not Significantly Disabled Participants in All Regions"
],
[
1000011,
"Significantly Disabled Participants in All Regions"
],
[
1000012,
"Significantly Disabled Participants in West Region"
],
[
1000002,
"All Disability Level Participants in West Region"
],
[
1000004,
"All Disability Level Participants in South Central Region"
],
[
1000009,
"Not Significantly Disabled Participants in South Central Region"
],
[
1000001,
"All Disability Level Participants in All Regions"
],
[
1000007,
"Not Significantly Disabled Participants in West Region"
],
[
1000015,
"Significantly Disabled Participants in East Region"
],
[
1000010,
"Not Significantly Disabled Participants in East Region"
],
[
1000005,
"All Disability Level Participants in East Region"
],
[
1000014,
"Significantly Disabled Participants in South Central Region"
],
[
1000003,
"All Disability Level Participants in North Central Region"
],
[
1000008,
"Not Significantly Disabled Participants in North Central Region"
]
]
}