I have a folder to store the text files which is declared outside the server folder. How to read the contents of that text file which is located outside server folder using jQuery.
Currently I am not able to read text files from jQuery.
<tr>
<td><input type=”checkbox” id=”par” name=”par” value=” <%=tempParam.getData()%>”></td>
<td><%=tempParam.getParameter().toUpperCase()%></td>
<td><%=tempParam.getDescription().toUpperCase()%></td>
<td><%=tempParam.getMission().toUpperCase()%></td>
<td><%=tempParam.getTelemetry().toUpperCase()%></td>
</tr>
<input class=”btn5″ type=”image” src=”images/images1.jpg” onclick=”javascript:graphplot()” name=”ok” title=”GRAPH PLOT” >
javascript:
function graphplot() {
var param = [],
nam = [];
var out = [];
var i, t = 0;
var url, filename, ff, url1, string2, mn, telnm;
var dataPointss = [],
arr = [
[]
];
var k = 3,
n = 0,
m = 0;
$.each($j(‘#hd1’).DataTable().rows().nodes().to$().find(‘input[type=”checkbox”]:checked’), function() {
url = $(this).val();
url = url.replace(/\\/gi, “/”);
filename = url.substring(url.lastIndexOf(“/”) + 1);
filename = filename.substring(0, filename.lastIndexOf(“.”));
ff = url.split(“/”).slice(7).join(“/”);
param.push(url);
});
if (param.length <= 5 || param.length > 0) {
for (n = 0; n < param.length; n++) {
var reader = new FileReader();
reader.onload = function(event) {
var contents = event.target.result;
alert(contents);
var allx = contents.split(‘\n’);
for (i = 3; i < allx.length; i++) {
allx[i] = allx[i].trim();
}
k = 3;
$.each(allx, function(k) {
if (allx.length > 0) {
var ally = allx[k].split(/ +/);
chart.options.data[m].dataPoints.push({
x: parseFloat(ally[0]),
y: parseFloat(ally[1])
});
k++;
}
});
chart.options.data[m].name = nam[m];
chart.render();
m++;
};
reader.readAsText(param[n]);
}
}
}
I expect a code help to read text file line by line and store in arraylist.