SamG wrote:
A client constructing a DHTML page and a user interacting with it still have to go to the web server just as if there were no DHTML. In the case of DHTML, even simple input validation has to be rechecked at the server if it's to be checked properly. It's a synchronous process, where the user has to wait for a full HTTP cycle to play out before moving on, pretty much regardless of what takes place at the client end. DHTML improves interactivity but doesn't tinker with the HTTP cycle, compared to a non-DHTML page.
Um....huh? You say that DHTML has to wait for a full HTTP cycle, but then again you say it doesn't tinker with it? I don't get it
As for input validation: every input should be validated by the final processing script, period. Validating input in JS is not jsut a pain in the ***, but it's also highly insecure if the php script just assumes checked input.
The major difference in between DHTML and AJAX is the way everything is handled. AJAX is a combination of three technologies: JavaScript (XMLHTTPRequest, or the Microsoft.XMLHTTP ActiceX object), a processing script (could be PERL, ASP, PHP, whatever), and XML.
Let me make an example for an easy usage of AJAX technology in a forum. As you all know, when trying to register with a username that has already been registered, you get an error when posting the form. Well, the change is easy: we create an onchange handler for the username field, which sends a request to a validation script (i.e. checkusername.php?username=foobar). The php script then checks the username, and returns an XML file, that could look like this:
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<response>
<result>1</result>
</response>
The processing JS object, that sent the request receives this information and allows as to parse through it. So via the DOM we grab what's written in between <result> and </result>, and we act accordingly to whatever is passed: for example, if the value is 0, we know that the username is already registered, therefore we have to show an error bar or something like it. You see, it's a bunch of things working together, but the only thing it does is this: it shows you that there's an error even before you post the form. This can save you some time, there's nothing more annyoing than having to post a signup form three times because all usernames you tried is used already.
One big advantage I see in AJAX (I think I've already mentioned it, but heck) is its speed. The request is sent, and not even a second later you see the result. That is because the request itself is only like 200 Bytes, and the response, well, see for yourself, that's about 200-300 Bytes. So we're talking half a KB here, which is something even the slowest dialup line could handle in a reasonable time.
Of course, you could easily do more messed up things (I've got a couple of those in my head and on my hard drive
), which makes the whole thing more complicated, but an easy example should demonstrate best, what it is, as some people are having problems with that.
Greetz
alcaeus