Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery 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 September 24th, 2010, 09:24 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 6: this.body is null error in all browsers

Hello. I'm working my way through the book, and encountered an issue.

Whenever I try to add a contact to the contact list, the app stops responding. With and error "Uncaught TypeError: Cannot call method 'appendChild' of null" on (around) line ~1345. I've tried this is Chrome, Firefox, and Safari on OSX. I've also tried strophe-1.0.1 and -master -- both have the issue.

It seems 'this.body' in that function is null, and I'm not sure how to proceed.
  #2 (permalink)  
Old September 24th, 2010, 09:31 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I should add that I had to change one line in 1.0.1 and -master.

Line ~1345 reads:
this.node.appendChild(elem);

This works in Firefox, but doesn't work in Chrome. There is a DOM error, relating to access. I /think/ this is because the element is used directly and not copied, so I tried to fix it like this:
this.node.appendChild(elem.cloneNode(true));
... and it seemed to work.

If I revert that fix, I get even less far. :-\
  #3 (permalink)  
Old September 24th, 2010, 10:24 AM
Registered User
 
Join Date: Sep 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

More updates ....

I originally added the cloneNode(true) code when I couldn't even get the Ch. 3 Hello / ping example to work; that addition solved it. However, since I've added a forward and reverse proxy for the http-bind from my web server to my xmpp server (ejabberd), I find I don't need flXHR. And removing that from Ch.3 and Ch.6 examples made both of them work better.

... Ch. 6 now has a "better error". Chrome gives the easiest to read error backtrace:
Code:
/~fafhrd/foobar/scripts/strophe.js:1505Uncaught TypeError: Object <li id='foxtrot-quarmall-apt'><div class='roster-contact offline'><div class='roster-name'>foxtrot@quarmall.apt</div><div class='roster-jid'>foxtrot@quarmall.apt</div></div></li> has no method 'find'
Strophe.Handler.run/~fafhrd/foobar/scripts/strophe.js:1505
(anonymous function)/~fafhrd/foobar/scripts/strophe.js:2792
Strophe.forEachChild/~fafhrd/foobar/scripts/strophe.js:692
Strophe.Connection._dataRecv/~fafhrd/foobar/scripts/strophe.js:2783
(anonymous function)/~fafhrd/foobar/scripts/strophe.js:403
Strophe.Connection._onRequestStateChange/~fafhrd/foobar/scripts/strophe.js:2640
(anonymous function)/~fafhrd/foobar/scripts/strophe.js:403
(anonymous function)/~fafhrd/foobar/scripts/strophe.js:440
(anonymous function)
So ... 1) Proxy in web server to xmpp server, good; flXHR, bad; 2) everything works in most browsers, 'cept for adding contacts to your list in Ch. 6 "Gab".
  #4 (permalink)  
Old December 5th, 2010, 04:34 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

I believe these types of errors are now fixed. cnode() now uses importNode() to bring in a node.

Let me know if you are still having trouble.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
display Null or Not an object error kishy449 Classic ASP Professional 1 September 4th, 2007 01:21 PM
null error crmpicco Javascript How-To 17 March 31st, 2005 07:35 AM
null exception error abhit_kumar JSP Basics 4 January 5th, 2005 05:26 PM
Response.Write output is of <body></body> yoord BOOK: Beginning ASP.NET 1.0 0 October 13th, 2004 07:06 AM





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