I am trying to send a list generated in Flask to Javascript. But I kept having this same issue. TypeError: Object of type 'Undefined' is not JSON serializable
Please help me.
My flask code is:
jsonString = json.dumps(LstSNV.serialize())
return render_template("spatial.html", AO_sDocument=occu, snvLst=jsonString)
My js in html page is:
let dataset = {{snvLst|tojson|safe}};
I even try to get the list directly from the html but failed.
function myFunction() {
var oldValue = document.getElementById('submit').value;
console.log(JSON.stringify(oldValue));
document.getElementById("submit").innerHTML = "LOADING...";
}
I think this problem is my list is undefined but i dont know how to convert it. Thank you.