I am trying to get the following code to become jslint-compliant, but am stuck on the following two errors:
Expected to see a statement and instead saw a block.
and
Unexpected 'this'.
What changes should I make to my code to make JSLint happy?
var pvAccess = {};
pvAccess.Func = function () {
"use strict";
function AccessPV(name, rValue, wValue) {
var url = '/goform/ReadWrite',
data = 'redirect=/response.asp&variable=' + escape(name),
xmlHttp = null,
wValue = null;
if (rValue !== null && rValue !== "") {
data += '&value=' + escape(rValue);
data += "&write=1";
} else {
data += '&value=none';
data += "&read = 1";
}
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 (e2) {
try {
// MS Internet Explorer (ab v5)
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e3) {
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 attribute of node
wValue.value = wValue[3];
return wValue;
}
}
};
xmlHttp.send(data);
}
}
// public
{
this.WritePV = function (name, value) { AccessPV(name, value); }
this.ReadPV = function (name, wValue) { return AccessPV(name, null, wValue); }
}
}
pvAccess = new pvAccess.Func();