Hi,
I am trying to use JSON.parse() to input a text from a file. However, My modle is
define(['ojs/ojcore', 'knockout', 'jquery','text!data/data.json','ojs/ojselectcombobox', 'ojs/ojchart'],
function(oj, ko, $,file) {
function DashboardViewModel() {
var self = this;
self.val = ko.observable("pie");
self.val = ko.observable("line");
self.stackValue = ko.observable('off');
self.orientationValue = ko.observable('vertical');
/* chart data */
var barSeries = JSON.parse(file);
var barGroups = ["Group A", "Group B"];
self.barSeriesValue = ko.observableArray(barSeries);
self.barGroupsValue = ko.observableArray(barGroups);
and the data.json file is below and I don't see any errors in it!
[{
"name": "Series 1",
"items": [42, 34]
},
{
"name": "Series 2",
"items": [55, 30]
},
{
"name": "Series 3",
"items": [36, 50]
},
{
"name": "Series 4",
"items": [22, 46]
},
{
"name": "Series 5",
"items": [22, 46]
}]
Here is the browser's error:
Navigated to http://localhost:8383/myFirstJET/index.html
text.js:325 GET http://localhost:8383/myFirstJET/js/data/data.json net::ERR_EMPTY_RESPONSE
text.get @ text.js:325
load @ text.js:204
(anonymous) @ require.js:1095
...
(anonymous) @ require.js:1460
setTimeout (async)
req.nextTick @ require.js:1815
localRequire @ require.js:1449
requirejs @ require.js:1797
(anonymous) @ main.js:54
ojcore.js:272 SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at new DashboardViewModel (dashboard.js:20)
at dashboard.js:88
at Object.execCb (require.js:1696)
at Module.check (require.js:878)
at Module.<anonymous> (require.js:1139)
at require.js:134
at require.js:1189
at each (require.js:59)
at Module.emit (require.js:1188)
Any help would be greatly appreciated.
CS