Wrox Programmer Forums
|
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
 
Old June 13th, 2006, 06:03 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3, Predictive Fetch error?

In the loadNextPage() function on page 53, the XMLHttp response text goes into the divLoadArea. Following this a new divPageN element is created. Next the divLoadArea is cleared. Is there a line missing to copy the content of the divLoadArea to the new divPageN element?

Also when the divPpageN element is created and appended to the document.body, the divNewPage variable is set to document.getElementById("divPage" + iNextPageToLoad). Since this element does not exist yet, is the variable set to null? Why not directly create a new div element?

Thanks,
Dave

 
Old June 14th, 2006, 09:06 AM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, I am confused about the purpose of the example. The technique I get, the example itself seems more than a little artificial though. Since the divs to be loaded are already part of the code for the page (a fact never mentioned in the printed code or the write up) it would be a whole lot simpler to just use css/js div hiding techniques and ditch the ajax altogether.
 
Old June 14th, 2006, 09:28 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I think you are missing the point of the example. Of course, you can output all three pages at once, but the example file doesn't do that. If you look at the code closely, you'll see it only returns one page at a time, depending on the query string parameters. I could have gone through the trouble of creating a database to store this information instead of throwing it into the PHP file, but I felt the example would be more succinct this way.

To answer your earlier question, the new DIV element is created as soon as the responseText is assigned to the loading area DIV using innerHTML. The returned text contains the definition of the DIV, which becomes a DOM object when passed into innerHTML. Then, you need to retrieve a pointer to that new DOM object (which was just created, so is no longer null).

You could just directly create the new DIV element, but this is a more elegant solution to ensure proper formatting.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
 
Old June 14th, 2006, 05:42 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nicholas,

Aha! Thanks for identifying the missing link - divPage elements within page responses in the php source file. I did download the source but only searched the javaScript source files. Perhaps in a future edition you could list more of the php file in the book.

FYI, "Professional AJAX" is a great resource! Just ordered additional copies for each member of my programming staff.

- Dave






Similar Threads
Thread Thread Starter Forum Replies Last Post
Fetch Data From server ashvinm JSP Basics 2 March 10th, 2008 07:48 AM
how to fetch records from website avats ADO.NET 0 November 3rd, 2005 03:45 PM
Nested Fetch statement cole SQL Language 0 May 11th, 2005 06:47 PM
fetch value cursor to table mateenmohd SQL Server 2000 2 August 2nd, 2004 06:41 AM
fetch in background? RCC_msolomon ADO.NET 6 June 25th, 2003 10:39 PM





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