Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 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
  #1 (permalink)  
Old October 28th, 2006, 12:44 PM
Registered User
 
Join Date: Oct 2006
Location: delhi, delhi, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shalesh
Default Best Picks Revisited - Example not working

I downloaded the chapter 4 example "Best Picks Revisited" from book Professional Ajax. As specified in the book i created a directory with name booklists in wwwroot folder on my machine which has iis as web server. Now when i run url "http://localhost/booklists/book.htm" in IE version 6 or mozilla firefox version 1.5, i get the error message "your browser doesn't support an XML HTTP Request." It is very frustrating for me as none of the examples from chapter 4 is working on my machine.

Please guide me what exactly is the issue and how that issue can be resolved. An early replay in this regard would be most appreciated.

Regards
Shalesh
  #2 (permalink)  
Old October 29th, 2006, 01:31 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Shalesh,

Try downloading a newer version of zXml (current version is 1.0.2) from http://www.nczonline.net/downloads/.

------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com
  #3 (permalink)  
Old November 1st, 2006, 07:16 AM
Registered User
 
Join Date: Oct 2006
Location: delhi, delhi, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shalesh
Default

Thanks for the reply. I downloaded the latest zxml.js from the location you specified. The example is running fine in both IE and mozilla. I am facing problem if i am implementing the example in another xslt file which is getting transformed on server side and the xslt code is given below.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Ajax Exercise</title>
    <script type="text/javascript" src="/zapak/js/zxml.js"></script>
    <script type="text/javascript">
    <![CDATA[
        function init(sFilename) {
            var oReq = zXmlHttp.createRequest();
            oReq.onreadystatechange = function () {
                if (oReq.readyState == 4) {
                    if (oReq.status == 200) {
                        transformXml(oReq.responseText);
                    }
                }
            };
            oReq.open("GET", sFilename, true);
            oReq.send();
        }

        function transformXml(sResponseText) {
            var oXmlDom = zXmlDom.createDocument();
            oXmlDom.async = false;
            oXmlDom.loadXML(sResponseText);
            var oXslDom = zXmlDom.createDocument();
            oXslDom.async = false;
            oXslDom.load("/xslshow.z?path=/testplayani");
            var str = zXslt.transformToText(oXmlDom,oXslDom);
            document.getElementById("divBookList").innerHTML = str;
        }
      ]]>
    </script>
</head>
<body onload="init('/topbarxml.z')">
    <div id="divBookList"></div>
</body>
</html>
    </xsl:template>
</xsl:stylesheet>


It is working fine in IE but it doesn't work in mozilla firefox version 1.5.0.7 . i get following errors in java script console....

Error: uncaught exception: Permission denied to call method Location.toString

Error: event.target.rel has no properties
Source File: chrome://global/content/bindings/tabbrowser.xml
Line: 791

Error: uncaught exception: [Exception... "Not enough arguments [nsIXMLHttpRequest.send]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://test2.zapak.com/zapak/js/book.htm :: init :: line 59" data: no]

please help.
  #4 (permalink)  
Old November 1st, 2006, 09:45 AM
Registered User
 
Join Date: Oct 2006
Location: delhi, delhi, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shalesh
Default

Sorry there was a mistake in my above message ...The sample code doesn't work in mozilla firefox version 1.5.0.7. it gives following error

Error: uncaught exception: [Exception... "Not enough arguments [nsIXMLHttpRequest.send]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://localhost/booklists/book.htm :: init :: line 19" data: no]

Regards
Shalesh
  #5 (permalink)  
Old November 1st, 2006, 10:12 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Mozilla's XMLHttpRequest needs an argument passed to the send method, even if it's an empty string or null. I thought that had been added to the zXml library but obviously not.
Try changing
Code:
oReq.send();
to
Code:
oReq.send("");

--

Joe (Microsoft MVP - XML)
  #6 (permalink)  
Old November 1st, 2006, 12:24 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

This is my fault. Code in the text, or in the examples, omitted the vital argument to the send() method.

Since you're doing a GET request, you should pass null to the send() method.

Code:
oReq.send(null);
That'll fix up the NS_ERROR_XPC_NOT_ENOUGH_ARGS error.


------------------------
Jeremy McPeak
Author, Professional Ajax
http://www.wdonline.com
  #7 (permalink)  
Old November 3rd, 2006, 10:40 AM
Registered User
 
Join Date: Oct 2006
Location: delhi, delhi, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shalesh
Default

Dear Jeremy,

Thanks for the help. I have a question which is related to doing multiple xml and xsl transformation using the function you have provided in the book "Professional Ajax" For example in my html page i use following piece of code...

<html>
<head>
 <script type="text/javascript" src="zxml.js"></script>
    <script type="text/javascript">
        function init(sFilename) {
            var oReq = zXmlHttp.createRequest();
            oReq.onreadystatechange = function () {
                if (oReq.readyState == 4) {
                    // only if "OK"
                    if (oReq.status == 200) {
                        transformXml(oReq.responseText);
                    }
                }
            };
            oReq.open("GET", sFilename, true);
            oReq.send();
        }

        function transformXml(sResponseText) {
            var oXmlDom = zXmlDom.createDocument();
            oXmlDom.async = false;
            oXmlDom.loadXML(sResponseText);


            var oXslDom = zXmlDom.createDocument();
            oXslDom.async = false;
            oXslDom.load("books.xsl");

            var str = zXslt.transformToText(oXmlDom,oXslDom);
            document.getElementById("divBookList").innerHTML = str;
        }

       </script>
</head>
<body onload="init('thisweekbooks.xml')">
<table>
<tr>
<td>
<div id="divBookList"></div>
</td>
<td>
    <div id="otherlist"></div>
<script language="javascript">
init('thisweekbooks.xml');
</script>
</td>
</tr>
</table>
</body>
</html>

In mozilla i get the following error....

Error: uncaught exception: Permission denied to call method Location.toString

(1) if i need to transform more than 1 xml using same xslt, how do i do it?
(2) if i need to transform more than 2 xml and each xml uses different xslt, how do i do it?

please help....

shalesh


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Issue revisited cedwards Dreamweaver (all versions) 13 June 21st, 2005 03:02 PM
.Net Windows Services Revisited - Help Rhonda Fischer General .NET 0 September 1st, 2004 12:36 PM
Excel Text Imports Revisited bph Access 5 April 1st, 2004 07:35 AM





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