I am getting the error
Could not complete the operation due to error c00c023f
when trying the open http request in Chapter 14.
Here is my code
validate_form.htm
<code>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Form Field Validator</title>
<styletype="text/css">
.fieldname
{
text-align: right;
}
.submit
{
text-align: right;
}
</style>
<scripttype="text/javascript"src="httprequest.js"></script>
<scripttype="text/javascript">
function checkUsername()
{
var userValue = document.getElementById("username").value;
if (userValue == "")
{
alert("Please enter a user name to check!");
return;
}
var url = "formvalidator.php?username=" + userValue;
var request = new HttpRequest(url, checkUsername_callBack);
request.send();
}
function checkUsername_callBack(sResponseText)
{
var userValue = document.getElementById("username").value;
if (sResponseText == "available")
{
alert("The username " + userValue + " is available!");
}
else
{
alert("We're sorry, but " + userValue + " is not available!");
}
}
function checkEmail()
{
var emailValue = document.getElementById("email").value;
if (emailValue == "")
{
alert("Please enter a email address to check!");
return;
}
var url = "formvalidator.php?email=" + emailValue;
var request = new HttpRequest(url, checkEmailname_callBack);
request.send();
}
function checkEmailname_callBack(sResponseText)
{
var emailValue = document.getElementById("email").value;
if (sResponseText == "available")
{
alert("The email " + emailValue + " is currently not in use!");
}
else
{
alert("We're sorry, but " + emailValue + " is not available!");
}
}
</script>
</head>
<body>
<formaction="">
<table>
<tr>
<tdclass="fieldname">
Username:
</td>
<td>
<inputtype="text"id="username"/>
</td>
<td>
<ahref="javascript: checkUsername()">Check Availability</a>
</td>
</tr>
<tr>
<tdclass="fieldname">
Email:
</td>
<td>
<inputtype="text"id="email"/>
</td>
<td>
<ahref="javascript: checkEmail()">Check Availability</a>
</td>
</tr>
<tr>
<tdclass="fieldname">
Password:
</td>
<td>
<inputtype="text"id="password"/>
</td>
</tr>
<tr>
<tdclass="fieldname">
Verify Password:
</td>
<td>
<inputtype="text"id="password2"/>
</td>
</tr>
<tr>
<tdcolspan="2"class="submit">
<inputtype="submit"value="Submit"/>
</td>
</tr>
</table>
</form>
</body>
</html>
</code>
httprequest.js
<code>
// JScript File
function HttpRequest(sUrl, fpCallback)
{
this.request = this.createXmlHttpRequest();
this.request.open("GET", sUrl, true);
var tempRequest = this.request;
function request_readystatechange()
{
if (tempRequest.readyState == 4)
{
if (tempRequest.status == 200)
{
fpCallback(tempRequest.responseText);
}
else
{
alert("An error ocurred trying to connect to the server");
}
}
}
this.request.onreadystatechange = request_readystatechange;
}
HttpRequest.prototype.createXmlHttpRequest = function ()
{
if (window.XMLHttpRequest)
{
var oHttp = new XMLHttpRequest();
return oHttp;
}
elseif (window.ActiveXObject)
{
var versions = ["MSXML2.XmlHttp.6.0",
"MSXML2.XmlHttp.3.0"];
for (var i = 0; i < versions.length; i++)
{
try
{
var oHttp = new ActiveXObject(versions[i]);
return oHttp;
}
catch (error)
{
}
}
}
returnnull;
}
HttpRequest.prototype.send = function ()
{
this.request.send(null);
}
</code>
Any help is greatly appreciated
Tom