Wrox Programmer Forums
|
BOOK: Beginning JavaScript 4th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 4th Edition by Paul Wilton, Jeremy McPeak; ISBN: 978-0-470-52593-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 4th Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2011, 02:55 PM
Authorized User
 
Join Date: Dec 2007
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default Chapter 14 http request open error

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
__________________
Thomas G Magaro





Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse Error on Chapter 14 pg 523 hozdaman BOOK: Beginning ASP.NET 4 : in C# and VB 3 August 10th, 2011 02:35 PM
Chapter 14 Code Error? pherank BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 4th, 2008 09:05 PM
Wrox United - chapter 14 - error SqlDependency tom_10000001 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 November 10th, 2006 06:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.