Because the issue appears to be caused by this line:
window.location.href = ''+ next_page +'.asp';
getting executed before your ajax call has completed, then the solution is to delay that line until the Ajax call has completed.
You can do that by adding a callback function to AccessPV so you can pass in a callback function that will be notified when the ajax operation is complete. Then, in WritePV(), pass in a callback function and change the window.location in that callback.
function check_value_text_box(next_page)
{
if ((!Value.value) || (Value.value.length > 4) || (Value.value > 359) || (Value.value < 0))
{
alert("ERROR: Please enter a number between and including 0 and 359.");
}
else
{
pvAccess.WritePV('_offset', document.getElementById('Value').value, function() {
window.location.href = ''+ next_page +'.asp';
});
}
}
pvAccess = {}
pvAccess.Func = function()
{
function AccessPV(name, rValue, wValue, fn)
{
var url = '/goform/ReadWrite';
var data = 'redirect=/response.asp&variable=' + escape(name);
if(rValue != null && rValue != "")
{
data += '&value=' + escape(rValue);
data += "&write=1";
}
else
{
data += '&value=none';
data += "&read=1";
}
var xmlHttp = null;
try {
// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
xmlHttp = new XMLHttpRequest();
} catch(e) {
try {
// MS Internet Explorer (ab v6)
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
try {
// MS Internet Explorer (ab v5)
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xmlHttp = null;
}
}
}
if (xmlHttp)
{
xmlHttp.open('POST', url , 1);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if(wValue != null)
{
wValue[3] = xmlHttp.responseText;
wValue[3] = wValue[3].replace("<!-- B&R ASP Webserver -->","");
// value attribut of node
wValue.value = wValue[3];
return wValue;
}
if (fn) {
fn(xmlHttp.responseText);
}
}
};
xmlHttp.send(data);
}
}
// public
{
this.WritePV = function(name, value, callback)
{
AccessPV(name,value, null, callback);
}
this.ReadPV = function(name,wValue)
{
return AccessPV(name, null, wValue);
}
}
}
pvAccess = new pvAccess.Func();