Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > BOOK: Beginning Ajax with ASP.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Ajax with ASP.NET
This is the forum to discuss the Wrox book Beginning Ajax with ASP.NET by Wallace B. McClure, Scott Cate, Paul Glavich, Craig Shoemaker; ISBN: 9780471785446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Ajax with ASP.NET 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
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 7th, 2008, 08:46 AM
Registered User
 
Join Date: Nov 2006
Location: , , United Kingdom.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default what's wrong with my code?

OK, so I was playing around with the Try it out on pg 85, and changed the function MakeXMLHTTPCall() to include a try/catch block:

<script type="text/javascript">
        <!--
            function MakeXMLHTTPCall()
            {
                try
                {
                    var xmlHttpObj = CreateXmlHttpRequestObject()
                    if(xmlHttpObj)
                    {
                        xmlHttpObj.open("GET", "http://" + location.host + "/Javascript Playground/DataFile.xml", true);
                        xmlHttpObj.onreadystatechange = function()
                        {
                           if(xmlHttpObj.status == HTTPSTATUS_OK)
                           {
                                alert("URL exist!");
                           }
                            if(xmlHttpObj.readyState == READYSTATE_COMPLETE)
                           {
                                // Extract the response text here and place in the div element.
                                document.getElementById("divResults").childNodes[0].nodeValue=xmlHttpObj.responseText;
                           }
                        }
                    }
                    xmlHttpObj.send(null);
                 }
                 catch(Err_msg)
                    {
                        var err_msg = "Could not locate url!\n\n";
                        err_msg += "Error code: " + err_msg.description;
                        alert(err_msg);
                    }

            }


While it "sort of works" I am not getting the desired result, in firefox it loop through my

if(xmlHttpObj.status == HTTPSTATUS_OK)
{
    alert("URL exist!");
}

portion of the code with the alert showing up three times, then it loads the the data. In internet explorer It as me if I wish to debug the code. The debugger breaks on the same section of code, which indicates that the value of xmlHttpObj.status is equal to "". Which I don't quite understand. In the end if I just ignore the error in IE, it does eventually load the xml file????

 


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
What's wrong with this code? appleseed C++ Programming 2 November 25th, 2006 08:17 AM
What's wrong with this code? AlDugan XSLT 3 May 19th, 2006 01:06 PM
What is wrong with code? rtr1900 Classic ASP Databases 1 April 3rd, 2006 04:20 AM
What is wrong with this code? SaharaWizard VB Databases Basics 2 January 28th, 2006 08:20 AM
what's wrong with this code? miguel.ossa ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2004 11:33 AM



All times are GMT -4. The time now is 03:38 PM.


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