Is it possible to set a variable in JavaScript to a local JSON file stored on computer?
var data = c/path/path/data.json
Is it possible to set a variable in JavaScript to a local JSON file stored on computer?
var data = c/path/path/data.json
If you are asking if you can access the file system with JavaScript the answer is yes and no. If you are using a tool like node.js then yes you can access the file system using JavaScript. If you are trying to access the file system from the browser then no JavaScript does not natively have that capability.
It really does not matter what you are trying to access on the file system. It could be JSON, jpg, or gif... If you are using a browser it is not possible..
However you can make ajax call to a server and get files that way. i.e. JSON files... You can also store information using JavaScript using the 'localstorage' method built into JavaScript.
You can make an Ajax request to get the external json.
$.ajax({
url: "c/path/path/data.json",
}).done(function(JsonToGet) {
var data = JsonToGet;
//Management of the JSON with 'data' variable.
});