I come from a Python programming background and had to do some Javascript stuff for codebehind(using VB.Net). I am able to manage but many articles I see are including JQuery, NodeJs and so.. I can now write in Javascript but not NodeJS, JQuery (which many articles show). That is totally a new dimension for me.
Problem:
In this, I am finding it really difficult to read a csv from a given local path in JS. In python it is very easy for me. But in JS, it seems near to impossible. I have 2 dropdowns and the values of 2nd dropdown should change based on selection in 1st dropdown. So I have used onchange
of attribute for elements of 1st dropdown. Then it jumps to JS where every dropdown selection gives me a directory path. Then in JS it should read a CSV present in this path and show this CSV data as options of 2nd dropdown. The following is one of my tries:
csv_path = "C:\data\models\driver\steering\steeringOut.csv";
// (csv_path will be updated on every item click in 1st dropdown)
var req = new XMLHttpRequest();
req.open("GET", csv_path, false);
req.onreadystatechange = function ()
{
if (req.readyState == 4 && req.status == 200)
{
allText = req.responseText;
allTextLines = allText.split(/\r\n|\n/);
}
}
This always outputs onreadystatechange as null
and readyState as 1
even though the csv is in the specified path. when googled, many articles that include JQuery or NodeJs. So that is not an option for me.This is very easy in Python but looks so difficult in JS. I have been struggling with this since a week and all my efforts seems useless in Javascript. Hence I reached out here incase if someone can help me.