p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Ajax ISBN: 978-0-471-77778-6 (http://p2p.wrox.com/forumdisplay.php?f=244)
-   -   book.htm problem in chapter 04 (http://p2p.wrox.com/showthread.php?t=42421)

50000 May 11th, 2006 12:39 PM

book.htm problem in chapter 04
 
I tested book.htm, but didn't get correct result, try debug and found:

function init(sFilename) {
    var oReq = zXmlHttp.createRequest();
    oReq.onreadystatechange = function () {
        alert(oReq.readyState)
        if (oReq.readyState == 4) {
            // only if "OK"
            alert(oReq.status)
            if (oReq.status == 200 || oReq.status == 0) {
                transformXml(oReq.responseText);
            }
        }
    };
    oReq.open("get", sFilename, true);
    oReq.send();
}


in FireFox "oReq.readyState" always show 1, and IE "oReq.status" only show 0. I use Firefox 1.0.7 and IE 6.0. Can anybody give me some help?

Thanks

jmcpeak May 11th, 2006 05:49 PM

A couple of things. First, and it's my fault that it is this way, oReq.send() should be oReq.send(null).

Secondly, how are you running this? Are you double clicking the .htm file?

In order for it to work properly, you must run the file off a web server. If you're running Windows 2000 or XP Pro, you can install IIS, place the .htm file (and other supporting files) in the c:\inetpub\wwwroot\ folder and point your browser to http://localhost/book.htm. If you're not running 2000 or XP Pro, you'll have to load PWS or Apache, place the files into the folders used by the server, and point your browser to the URL I listed earlier.

If neither of those solutions work, come back and we'll go from there.

------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com

50000 May 15th, 2006 07:16 PM

Thanks for the help, now I am running on server, I can tell the oReq.status is 200, the only thing didn't work is
var str = zXslt.transformToText(oXmlDom,oXslDom);
the value of str is blank, from alert(sResponseText), it shows the xml data. I just don't know how to check
oXmlDom.loadXML(sResponseText); and
oXslDom.load("books.xsl");

Thanks


nzakas May 15th, 2006 08:22 PM

You should check the value of the DOMs using the xml property:
Code:

alert(oXmlDom.xml);
alert(oXslDom.xml);

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/

50000 May 16th, 2006 11:58 AM

It is working now, Thanks


50000 May 16th, 2006 06:22 PM

Mr. Zakas,

My test only work for IE

alert(oXmlDom.xml)
alert(oXslDom.xml)

with FireFox alert(oXmlDom.xml) shows the content, but
alert(oXslDom.xml) return blank. I am not sure what is wrong, and how to debug oXslDom for FireFox.

Thanks

James



All times are GMT -4. The time now is 07:27 AM.

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