Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript 4th Edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 6th, 2011, 02:55 PM
Authorized User
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: Phoenix, AZ, USA.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 03: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 10: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



All times are GMT -4. The time now is 12:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.