AJAX support?

Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here.
Forum rules
Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here. Feature requests are closed.
SamG
Registered User
Posts: 1241
Joined: Fri Aug 31, 2001 6:35 pm

Re: AJAX support?

Post by SamG »

markus_petrux wrote: ... perform the requests to the server, process the responses and using innerHTML (supported by almost all browsers these days) or whatever to update the page on the browser....
That's where the difference lies, the interaction path between client and server.

This introduction is better than any I could offer.
markus_petrux
Registered User
Posts: 376
Joined: Fri Jun 18, 2004 10:58 pm
Location: Girona, Catalunya (Spain)
Contact:

Re: AJAX support?

Post by markus_petrux »

Sure, that's really cool. However, the same effect can be achieved using DHTML. The only problem with DHTML is making it cross-browser is not obvious, but still possible. At least more cross-browser than using AJAX related technologies, which, as far as I've seen, are based on non-public standards.

Using DHTML, a user action may trigger a javascript function to perform an HTTP request on a hidden IFrame, the server may return a javascript stream which at onload event of that document, javascript code can update a form field, the contents of a layer, etc.

Both methods (DHTML and AJAX) depend on JavaScript. The DHTML option was here before. Why nobody asked phpBB devs to do it? I guess it is because javascript may easily break the accessibility of the page, so this kind of things are perfect to be added by MODs. Every webmaster can choose to add it or not. Also MODs may evolve more quickly than phpBB itself, to adapt to new browsers, etc.

AJAX might be as complex as it was/is DHTML. Which means these techniques may still evolve until they reach a point where a public standard can be written/agreed by everyone.
SamG
Registered User
Posts: 1241
Joined: Fri Aug 31, 2001 6:35 pm

Re: AJAX support?

Post by SamG »

The same effect might be possible with DHTML (depending on the effect), but not at the same speed. The AJAX engine replaces the normal HTTP client request process, and that's where the big bang is at for AJAX. It's a matter of removing the normal HTTP network connect/request/process/send loop latency.

DHTML and AJAX share some common technologies, as you're pointing out, but they really aren't the same thing in any sense, if I'm understanding it right.
User avatar
cyberCrank
Registered User
Posts: 560
Joined: Wed Jan 28, 2004 3:38 am
Location: Ethereal Bliss

Re: AJAX support?

Post by cyberCrank »

Seeing the performance in some of the big-boy apps (Gmail, Google Map, etc.) makes one realize the speed advantage in AJAX technology, which in time will become fairly common. However, I am torn from wanting it in phpBB 3.0 for very responsive performance, but sort of desire to just get 3.0 out the door and maybe then couple AJAX into with 3.2. It will be interesting to see which way the Devs decide to go...
alcaeus
Registered User
Posts: 66
Joined: Sun Oct 10, 2004 3:21 am
Location: Munich (Germany)
Contact:

Re: AJAX support?

Post by alcaeus »

I have implemented some AJAX feature into a local testing forum (2.0.16), and I must admit, the speed actually surprised me. Also, I coded the thing together, and it instantly worked in IE, Firefox, Opera and Safari, I didn't have anything else to test it with ;)
As long as you keep it as an addition (i.e. instantly validating input), having it can't really be a loss, because even if one of the users doesn't have JS or ActiveX (IE only) active, it doesn't matter. Well, they won't be able to use any cool AJAX stuff, but the rest will work normal for them. I'm still working on a few different things, thinking about how to tweak one feature in particular, and then you'll probably see it in the MOD database on the main page ;)

Greetz
alcaeus
markus_petrux
Registered User
Posts: 376
Joined: Fri Jun 18, 2004 10:58 pm
Location: Girona, Catalunya (Spain)
Contact:

Re: AJAX support?

Post by markus_petrux »

SamG wrote: The same effect might be possible with DHTML (depending on the effect), but not at the same speed. The AJAX engine replaces the normal HTTP client request process, and that's where the big bang is at for AJAX. It's a matter of removing the normal HTTP network connect/request/process/send loop latency.

DHTML and AJAX share some common technologies, as you're pointing out, but they really aren't the same thing in any sense, if I'm understanding it right.
I'm not telling DHTML and AJAX are the same thing, but they both may serve the same purpose.

With AJAX and DHTML there should be a script in the server to process the HTTP request. This script would have to load all common phpBB stuff, perform user session check, etc. in both cases. I believe AJAX generates XML (I might be wrong here), with DHTML you can generate HTML, javascript or whatever. I don't believe DHTML to be slower than AJAX, it depends on how much work the browser and server should do. I guess AJAX needs to load more stuff on the browser. The good for DHTML is it may run on most browsers than AJAX.

Out of curiosity (I can't resist), I'll try to write a "dynamic preview" for posting.php using DHTML to see how fast/slow it runs. If I'm able to do it, then it could be compared with wGEric MOD based on AJAX.

edited: hmm... I got it, I posted it here:
http://www.phpbb.com/phpBB/viewtopic.php?t=308001" target="_blank

If anyone wants to give it a try... maybe just to compare.
markus_petrux
Registered User
Posts: 376
Joined: Fri Jun 18, 2004 10:58 pm
Location: Girona, Catalunya (Spain)
Contact:

Re: AJAX support?

Post by markus_petrux »

I've just found an article describing the technique I've used above.

http://developer.apple.com/internet/web ... frame.html" target="_blank

This is much simpler than AJAX, uses less code and works on more browsers.
alcaeus
Registered User
Posts: 66
Joined: Sun Oct 10, 2004 3:21 am
Location: Munich (Germany)
Contact:

Re: AJAX support?

Post by alcaeus »

Comparing AJAX with DHTML is (IMO) not something you should do. They are two completely different approaches to a (more or less) similar problem. The advantage I see in AJAX is it's "size". I send out a request, and the XML that is generated is (in most cases) less than 200 Bytes. One of the features I tested out worked pretty darn fast even on a dialup modem. Using your iframe-solution would actually force the user to completely download a whole phpBB page, unless you provide additional scripts ;)

Greetz
alcaeus
SamG
Registered User
Posts: 1241
Joined: Fri Aug 31, 2001 6:35 pm

Re: AJAX support?

Post by SamG »

markus_petrux wrote: I'm not telling DHTML and AJAX are the same thing, but they both may serve the same purpose....
I also said they may serve the same purpose (depending). Advocates of AJAX have described the advantages better than I can, but again, the difference between AJAX and DHTML is in the way the HTTP process is handled.

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.

AJAX handles this cycle differently in a fundamental way, and at that fundamental difference the comparison between DHTML and AJAX ends, I think.
alcaeus
Registered User
Posts: 66
Joined: Sun Oct 10, 2004 3:21 am
Location: Munich (Germany)
Contact:

Re: AJAX support?

Post by alcaeus »

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
Post Reply