Hello. I’m new to HOT and am trying to reproduce the “Saving Data” example in your documentation at the link below.
https://handsontable.com/docs/saving-data/#overview
However, instead of using the “ajax” method provided in your code to load data into the table, I’m trying to use the jquery “$.ajax” method instead and it is returning the error:
“unexpected token u in json at position 0 at json.parse (anonymous)”
I understand what the error is, but do not understand why the error is occurring.
Here is the snippet from your code which is referring to the ajax function in the code:
ajax(’/docs/11.1/scripts/json/load.json’, ‘GET’, ‘’, res => {
const data = JSON.parse(res.response);
hot.loadData(data.data);
exampleConsole.innerText = ‘Data loaded’;
});
Here is what I’m trying to use instead which is using jQuery AJAX:
$.ajax({url: ‘data/load/load.json’, method: ‘GET’, dataType: ‘json’, success: res => {
const data = JSON.parse(res.response);
hot.loadData(data.data);
exampleConsole.innerText = ‘Data loaded’;;
}});
There error is in “JSON.parse(res.response)”. It usually means that the JSON being sent to that method is undefined or in the wrong format, but I am using the same exact data in your code (at https://handsontable.com/docs/11.1/scripts/json/load.json and it’s in a proper JSON format.
I’ve tried multiple things and read through your forum and others and have not had any luck.
Any ideas?