You define var scatterSeries = [];
, and then try to parse it as a json string at console.info(JSON.parse(scatterSeries));
which obviously fails. The variable is converted to an empty string, which causes an "unexpected end of input" error when trying to parse it.