Reputation: 163
I have a text file with the following content with each line representing a new object. The text file is stored locally on a PC e.g. C:\data
.
Name,Role
PersonA,Administrator
PersonB,Engineer
As we are limited to using a session provided by a third party tool, we cannot use reference jQuery libraries or AJAX.
I would like the content to loop through as follows;
var p = {
"PersonA" : "Administrator",
"PersonB" : "Engineer"
};
for (var key in p)
{
if (p.hasOwnProperty(key))
{
client = selectedPackage.Elements.AddNew(key, p[key]);
client.Update();
}
}
How do I reference a complete path e.g. c:\data\roles.txt
and have its content loop through?
Upvotes: 0
Views: 74
Reputation: 288120
JavaScript is limited, so
Then, I think the best solution is making the file accessible in your server, and get it using AJAX.
And if you say you can't use AJAX, maybe you could try using an input to load the file, and save it using localStorage
for future uses.
Upvotes: 1
Reputation: 144912
In a browser? The only way to get access to a file on disk is by letting the user select the file with an <input type="file">
and then using the HTML5 File API to read its contents.
Upvotes: 1