Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional Ajax ISBN: 978-0-471-77778-6
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 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 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
__________________
shalesh
Reply With Quote
  #2 (permalink)  
Old October 29th, 2006, 12:31 PM
jmcpeak's Avatar
Wrox Author
Points: 361, Level: 6
Points: 361, Level: 6 Points: 361, Level: 6 Points: 361, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 77
Thanks: 0
Thanked 12 Times in 12 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
Reply With Quote
  #3 (permalink)  
Old November 1st, 2006, 06: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.
Reply With Quote
  #4 (permalink)  
Old November 1st, 2006, 08: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
Reply With Quote
  #5 (permalink)  
Old November 1st, 2006, 09:12 AM
joefawcett's Avatar
Wrox Author
Points: 9,731, Level: 42
Points: 9,731, Level: 42 Points: 9,731, Level: 42 Points: 9,731, Level: 42
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,068
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)
Reply With Quote
  #6 (permalink)  
Old November 1st, 2006, 11:24 AM
jmcpeak's Avatar
Wrox Author
Points: 361, Level: 6
Points: 361, Level: 6 Points: 361, Level: 6 Points: 361, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 77
Thanks: 0
Thanked 12 Times in 12 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
Reply With Quote
  #7 (permalink)  
Old November 3rd, 2006, 09: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
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
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 06:35 AM



All times are GMT -4. The time now is 09:44 AM.


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