Here is a little demo you might find interesting. There may be more efficient methods and I am not sure how this will react with large data files, hopefully someone with a clue on that will contribute to this thread. Also, since you say you already have this big file with the values in it, you could test it out on that and see how much lag time there is with a large file being parsed for individual values. For the purposes of this demo, I created data.txt and get_data.htm -
data.txt
------------------------
A1=99
A2=3
A3=255
------------------------
get_data.htm
------------------------
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Get Data - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function getFile(filename)
{ oxmlhttp = null;
try
{ oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e)
{ try
{ oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{ return null;
}
}
if(!oxmlhttp) return null;
try
{ oxmlhttp.open("GET",filename,false);
oxmlhttp.send(null);
}
catch(e)
{ return null;
}
return oxmlhttp.responseText;
}
function getData(file, param){
return getFile(file).split(param+'=', 2)[1].split('\n', 1)[0]
}
</script>
</head>
<body>
<input type="button" onclick="alert(getData('data.txt', 'A1'))" value="A1"><br>
<input type="button" onclick="alert(getData('data.txt', 'A2'))" value="A2"><br>
<input type="button" onclick="alert(getData('data.txt', 'A3'))" value="A3"><br>
</body>
</html>
Bookmarks