Go Back   SitePoint Forums > Forum Index > Program Your Site > JavaScript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 12, 2005, 20:50   #1
ArticleBot
SitePoint Articles
 
ArticleBot's Avatar
 
Join Date: Apr 2001
Posts: 0
Article Discussion

This is an article discussion thread for discussing the SitePoint article, "AJAX: Usable Interactivity with Remote Scripting"
ArticleBot is offline   Reply With Quote
Old Jul 12, 2005, 20:50   #2
Brak
SitePoint Addict
 
Brak's Avatar
 
Join Date: Jul 2004
Location: Central Coast, CA
Posts: 365
And not one mention of Prototype? Rico? An article about AJAX without including the immensely helpful AJAX libraries is near a sin.
Brak is offline   Reply With Quote
Old Jul 13, 2005, 01:55   #3
AlexW
Team SitePoint
 
AlexW's Avatar
 
Join Date: Apr 2000
Location: Melbourne
Posts: 1,004
Well, it's really an article on 'AJAX usability', rather than everything AJAX.
AlexW is offline   Reply With Quote
Old Jul 13, 2005, 02:08   #4
andrin
SitePoint Addict
 
Join Date: Nov 2003
Location: Malmoe, Sweden
Posts: 265
Itīs a nice article but I must object to the use of try/catch. Now try/catch is great but older browsers (if one cares) donīt implement it so their JavaScript interpreter will crash. Why not use old fashioned object detection Cameron?
andrin is offline   Reply With Quote
Old Jul 13, 2005, 02:47   #5
Kevinn
SitePoint Community Guest
 
Posts: n/a
Very, very nice tutorial!

Printer friendly version of this article is a no show though!
  Reply With Quote
Old Jul 13, 2005, 04:07   #6
Sorccu
SitePoint Guru
 
Join Date: Jun 2004
Location: Finland
Posts: 709
I can't believe you're using innerHTML. Sure it's faster to write, but it's definitely NOT the way to go.
Sorccu is offline   Reply With Quote
Old Jul 13, 2005, 04:31   #7
Dean C
SitePoint Wizard
 
Dean C's Avatar
 
Join Date: Mar 2003
Location: England, UK
Posts: 2,964
I enjoyed reading this, thanks :)!
Dean C is offline   Reply With Quote
Old Jul 13, 2005, 04:33   #8
bianster
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 42
Rather than reinventing a thousand wheels, why not consider using the excellent Prototype javascript library. It provides abstraction of lower level details and provides a lot of functionality out of the box.

Unless you're trying to implement another customer library(groan...) this would a great resource, IMHO

EDIT: Oops, didn't see the post by Brak
bianster is offline   Reply With Quote
Old Jul 13, 2005, 05:46   #9
Anup
SitePoint Community Guest
 
Posts: n/a
This is interesting and useful. On accessibility though, while you note not depending on JavaScript, you should be aware that most screen reader users have JavaScript enabled. Accessibility is not about having JS on or off. Screen readers will also have a problem with these forms, as when the new/updated content appears, they will jump to that text, which will thoroughly diorient those users. How you address this I don't know. Ajax sounds interesting and is taking off, but it is opening more accessibility issues, I think. Perhaps people can suggest alternatives that do not involve an alternative site? Any ideas?
  Reply With Quote
Old Jul 13, 2005, 12:42   #10
velocd
ŋuʍop ǝpısdn ʎɥʍ
 
velocd's Avatar
 
Join Date: Aug 2002
Location: San Jose, CA
Posts: 456
Quote:
Originally Posted by Sorccu
I can't believe you're using innerHTML. Sure it's faster to write, but it's definitely NOT the way to go.
I read this often, the problem is whenever you guys state such a claim you fail to enlighten the reader (without ambiguity) what the alternative is to innerHTML.

Assuming myDiv exists:

innerHTML method

Code:
document.getElementById('myDiv').innerHTML = '<span class="largeFont">Hello world!</span>';
DOM method

Code:
document.getElementById('myDiv').appendChild(document.createElement('span'));
document.getElementById('myDiv').firstChild.className = 'largeFont';
document.getElementById('myDiv').firstChild.appendChild(document.createTextNode('Hello world!'));
Or more commonly used (when firstChild/lastChild isn't the parent):

Code:
var spanElement = document.createElement('span');
spanElement.className = 'largeFont';
document.getElementById('myDiv').appendChild(spanElement);

spanElement.appendChild(document.createTextNode('Hello world!'));
DOM requires you to create a text node, which must have plain text inside. HTML must be added using appendChild() and createElement() then creating the text node inside.

innerHTML is faster, not to mention very easy to use.

It creates all the hierarchical pointers that regular DOM fashions, i.e. using alert(document.getElementById('myDiv').firstChild.firstChild.nodeValue); would print "Hello world!"

So why shouldn't we use innerHTML? Why do hardcore DOM enthusiasts condemn equivocally about it?

I don't fully know, which is why I'm open to interpretation.

For one it's not part of W3C standards, but neither is XmlHttpRequest.

Quote:
Originally Posted by Brak
And not one mention of Prototype? Rico? An article about AJAX without including the immensely helpful AJAX libraries is near a sin.
Those are some crazy libraries. The syntax in files such as this one is stuff I haven't seen yet in JS. I've known of prototypes and classes, but whoa.

Unfortunately there is a virtually no official documentation on Prototype.. probably why the author of this article didn't consider it so not to confuse the reader.
velocd is offline   Reply With Quote
Old Jul 13, 2005, 13:26   #11
Dr Livingston
Non-Member
 
Join Date: Jan 2003
Posts: 5,799
> So why shouldn't we use innerHTML?

Because it is not part of the w3c standard, and that is why you shouldn't use it as future browsers may not actually support it's use.

Netscape 6 had it for backward compatibility only, and mozilla followed suit. Use the DOM for obvious reasons I say :)
Dr Livingston is offline   Reply With Quote
Old Jul 13, 2005, 13:58   #12
Ryan Wray
SitePoint Addict
 
Join Date: Jan 2005
Location: Ireland
Posts: 376
Quote:
Originally Posted by Dr Livingston
Because it is not part of the w3c standard, and that is why you shouldn't use it as future browsers may not actually support it's use.
He actually acknowledged that, and brang up a valid point:

Quote:
Originally Posted by velocd
For one it's not part of W3C standards, but neither is XmlHttpRequest.
But, on the other hand, it is likely that XmlHttpRequest will be supported by all future browsers; innerHTML will probably not always be supported (as Dr Livingston pointed out). In fact, I was under the impression that if you serve a page as application/xhtml-xml, innerHTML will not work. So, you may find yourself re-writing your scripts if you decide to use this MIME-type (once IE supports it, or before if you're into content negotiation).
Ryan Wray is offline   Reply With Quote
Old Jul 13, 2005, 15:38   #13
bigduke
.50 cal to the head
 
bigduke's Avatar
 
Join Date: May 2004
Location: Australia
Posts: 864
Just yet another how-to article to promote n00b'ism
bigduke is offline   Reply With Quote
Old Jul 13, 2005, 15:44   #14
Themaninblue
SitePoint Author
 
Join Date: Jul 2005
Posts: 3
Hi Guys,

Thanks for the comments.

Just to clear up a few points:

- Although there are a few library implementations of remote scripting technologies, none of them is dominant at this point in time. Additionally, the code needed to get XMLHttpRequest going isn't that complex, so you shouldn't need a large library to have a little feature on your page. Wouldn't you much rather know how to do it yourself, then have the choice of using a library?

- I tried to make the code as simple to follow as possible, hence my use of innerHTML for the completion page. I would normally use standard DOM methods to create HTML elements (such as was done for the error messages), but as that was not the main thrust of the article, I figured for brevity I would forego the long list of elements and text nodes.

- Quite right, if you really care about the < 1% of users who use a browser that doesn't support try/catch, then check for XMLHttpRequest support using if statements:

Code:
if (typeof XMLHttpRequest != "undefined")
{
...
}
Themaninblue is offline   Reply With Quote
Old Jul 13, 2005, 21:16   #15
McGruff
simple tester
 
McGruff's Avatar
 
Join Date: Sep 2003
Location: Glasgow
Posts: 1,680
An alternative view of Ajax: Listen Kids Ajax is Not Cool
McGruff is offline   Reply With Quote
Old Jul 13, 2005, 22:21   #16
Sorccu
SitePoint Guru
 
Join Date: Jun 2004
Location: Finland
Posts: 709
Quote:
Originally Posted by velocd
I read this often, the problem is whenever you guys state such a claim you fail to enlighten the reader (without ambiguity) what the alternative is to innerHTML.
The article being a bit more advanced, I thought that readers would already know how to do it properly. You've got a point, anyway.
(By the way, innerHTML is actually slower in Mozilla.. there were tests about this somewhere.. can't remember where.)
Quote:
Originally Posted by Themaninblue
- I tried to make the code as simple to follow as possible, hence my use of innerHTML for the completion page. I would normally use standard DOM methods to create HTML elements (such as was done for the error messages), but as that was not the main thrust of the article, I figured for brevity I would forego the long list of elements and text nodes.
I know It's just that using it in articles/blogs/whatever encourages others to do so. Nearly offtopic: And what about XHTML? Don't know about you but it seems a bit illogical to me to be using innerHTML in an xml-compliant document. Time for innerX(HT)ML, eh?

Edit: Oh, I should probably mention this:

The article was very good. Looking forward to more articles from you. In case you're open to suggestions, I'd really like to know more about (XMLHttpRequest &) XPath. A non-feature article would be great, too

Last edited by Sorccu; Jul 14, 2005 at 05:26.
Sorccu is offline   Reply With Quote
Old Jul 14, 2005, 10:19   #17
Julien Couvreur
SitePoint Community Guest
 
Posts: n/a
It seems simpler to use the onload and onerror events on XMLHttpRequest, rather than the onreadychangestate.

Let me also plug my XMLHttpRequest tracing and debugging scripts (for Firefox), which let you easily see what interactions your page is doing in the background. You can get them from:
http://blog.monstuff.com/archives/000252.html
  Reply With Quote
Old Jul 14, 2005, 13:53   #18
redbone
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 58
Quote:
Originally Posted by Themaninblue
- Although there are a few library implementations of remote scripting technologies, none of them is dominant at this point in time. Additionally, the code needed to get XMLHttpRequest going isn't that complex, so you shouldn't need a large library to have a little feature on your page. Wouldn't you much rather know how to do it yourself, then have the choice of using a library?
I guess one of the advantages of using a library like prototype is that its heavily used in Rapid Development framewords like Ruby on Rails and Perl's Catalyst.
redbone is offline   Reply With Quote
Old Jul 14, 2005, 14:54   #19
mutant
SitePoint Enthusiast
 
mutant's Avatar
 
Join Date: Apr 2004
Location: Gallifrey
Posts: 29
^^ Marcus wrote the "Ajax isn't cool" article:
http://www.lastcraft.com/blog/index.php?p=19

I don't think he could have been more wrong. I believe the points he makes are very weak considering adoption of this technology will strengthen it. Saying something isn't cool because its immature doesn't take a longer view of things.. Marcus had this all wrong.. IMOHO
mutant is offline   Reply With Quote
Old Jul 14, 2005, 17:17   #20
Mike Schinkel
SitePoint Community Guest
 
Posts: n/a
AJAX is great, but be careful:
http://blogs.xtras.net/mikes/AJAXAPanaceaOrAPendingTrainWreck.aspx
  Reply With Quote
Old Jul 14, 2005, 17:33   #21
BHynum
SitePoint Community Guest
 
Posts: n/a
Best AJAX article/example i'v seen so far. Thx.
  Reply With Quote
Old Jul 15, 2005, 07:32   #22
Jason O'Brien
SitePoint Community Guest
 
Posts: n/a
This was a great article! Going through the parameters, methods and properties and explaining their purpose and values made this read like a condensed SDK for AJAX.

I don't feel that AJAX is a suitable tool for any public sites I will produce. Considering the amount of additional development time invested in writing a seperate process for browsers not supporting the components of AJAX. Now for intranet applications or applications where the environment is controlled then this will be terrific.
  Reply With Quote
Old Jul 17, 2005, 04:19   #23
andy moss
SitePoint Community Guest
 
Posts: n/a
if you are generating the xml dynamically on iis using asp3 what is the best approach for sending the content type? would it be best to set a new file extension like .axml and set that to be processed and send the content type as text/xml or would you still have to put the content type into the asp code?
  Reply With Quote
Old Jul 17, 2005, 22:59   #24
Themaninblue
SitePoint Author
 
Join Date: Jul 2005
Posts: 3
Andy, I'm not too familiar with ASP, but it's definitely safest to send the correct content header, otherwise you won't know exactly how the user's browser is going to parse it at the other end.
Themaninblue is offline   Reply With Quote
Old Jul 18, 2005, 08:01   #25
whitehouse
SitePoint Member
 
Join Date: Apr 2004
Location: Dordrecht, Netherlands
Posts: 7
nice article!

one question I have though:

it only checkes the xml once..
I added some db-code in the request.php, so when a number is given, it returns the name / email address and put's it in the right fields. But when re-enter the receipt-number, it does not change the name/email fields.. so my question : what is the reason that it does not refresh the fields after entering the right receipt-number for the first time ?
whitehouse is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

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 On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 12:53.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved