View Full Version : AJAX for dummies thread
123GoToAndPlay
Aug 17th 2006, 5:25 am
Just like to know more about the subject.
Some general questions:
1/ AJAX = Javascript +CSS +httprequests + xml???
2/ AJAX is just a general term of using a combo of existing "languages"??
3/ AJAX is an example of Web 2.0??
4/ Can anyone provide a simple "Hello World" in AJAX??
afactory
Aug 17th 2006, 5:39 am
Here a "Hello World" in AJAX:
http://www.dynamicajax.com/fr/AJAX_Hello_World-271_290_322.html
123GoToAndPlay
Aug 17th 2006, 7:12 am
tx, afactory.
That's a lot of code to say hello ;)
afactory
Aug 17th 2006, 7:15 am
Yeap, but AJAX applications looks pretty nice ;) after all the code will be done.
phper
Aug 17th 2006, 6:07 pm
Another important element of AJAX is DOM, although a lot of web apps that claim
to use AJAX don't make use of this. For example, the server simply returns all the HTML code, and then JavaScript simply uses object.innerHTML = theHtmlCode to
update the HTML content. We can't really argue whether this is still considered
AJAX, because there's no "official" definition for AJAX.
An easy-to-follow guide for beginners can be found here (http://www.php-etc.com/tutorials/Ajax/)or here (http://developer.mozilla.org/en/docs/AJAX:Getting_Started).
123GoToAndPlay
Aug 18th 2006, 12:48 am
@phper, tx for the links.
I am still trying to grasp the "thought" behind AJAX. But the more I read the more questions I have:
- why or better yet when should I use AJAX
- major advantage of AJAX over "just" php/mysql (client vs serverside I recon?)
- is this the future?? or is it like .wml
btw: your second link (http://developer.mozilla.org/en/docs/AJAX:Getting_Started) is quit clear for a beginner
RyanSmith345
Aug 18th 2006, 10:01 am
The thing that you need to understand about AJAX, and its basic underlying concept is that you can change content on the page from the server without having to refresh the entire page.
There is no real definiton of what is and what isn't AJAX, but I consider anything to be AJAX that makes use of the XmlHttpRequest object to dynamically update the page.
When is the useful? Certainly not in every situation. You should not use AJAX to replace day to day web functions. However, it can be extreamly useful in may places and make the web a much more usable environment.
For example, take the Digg voting system. When you "digg" an article it makes an asyncronous request to the server to submit your vote without the need to refresh the entire page. Very useful.
AJAX also makes things like web chat possible. Take for example:
http://www.dynamicajax.com/chat.php
It automatically updates without refreshing the entire page. If you like that example, here is a complete tutorial:
http://www.dynamicajax.com/fr/AJAX_Driven_Web_Chat-271_290_291.html
Probably the best example of AJAX is http://maps.google.com
Google Maps is easily one of the best web applications out there, and it is only possible because of AJAX technologies.
Just remeber, don't use AJAX for the sake of AJAX. But if you have a good legitimate, it can add quite a bit to your site.
123GoToAndPlay
Aug 20th 2006, 3:02 am
Hi all,
I think I just made my first simple AJAX file
www.everybodyneeds2drawmickeyonce.com/ajax.html
Just ctrl-c and ctrl-v ;)
Purpose:
- to learn
- create code which users can use on their own website. User just have to paste
<script language="JavaScript" type="text/javascript" src="http://www.everybodyneeds2drawmickeyonce.com/ajaxFunctions.js"></script>
and
<span id="top10_result" style="cursor: pointer; text-decoration: underline; background-color:#FFFFFF;" onclick="makeRequest('http://www.everybodyneeds2drawmickeyonce.com/top10.php')">
Show top-10 list of mickeys
</span>
Questions:
- Does this qualify as an AJAX appli??
- Is this a right use of AJAX??
Regards
123GoToAndPlay
Aug 20th 2006, 3:59 am
hmmm, tested it on another domain and it doesn;t work :(
[edit] Ah, we can't use use XMLHttpRequest to access resources on another domain than the one where the script is executing
RyanSmith345
Aug 29th 2006, 7:34 am
Ya, that's the problem with AJAX. You can't make cross-domain calls. So you can't just simply create a piece of code that anyone can paste in. There has to be something running on their backend.
I'm still trying to figure out how this is a security issue. Seems like if you wanted to make a cross domain call, no big deal.
phper
Aug 29th 2006, 6:48 pm
It IS actually a big deal.
And cross-domain limitation is not only for Ajax, but for javascript in general
as well.
A simple example:
I created a website on www.mydummysite.com (not my real website, just an example), which has an iframe that links to this forum website (forum.digitalpoint.com). Just to add to the fun, I made this iframe have 0 width and 0 height (thus invisible) so user is unaware of it. If cross-domain javascript was allowed, I could then easily get your cookies set for this forum.digitalpoint.com from my website by accessing the hidden iframe I created.
I could also post a message to this forum with your login details without you knowing it (wouldn't even need to steal your cookies to do this). Other potential malicious things that could be done are limitless.
Alis
Aug 29th 2006, 7:06 pm
Ajax is old you know :) There is a better technology then ajax it just replaced it ...
RyanSmith345
Aug 30th 2006, 6:56 am
The XmlHttpRequest Object (the core of AJAX) has been around since IE 5, but the term AJAX didn't get coined until about a year and a half ago.
Currently there is no other browser technology that allows you to make asynchronous calls unless you are using Flash, a Java applet, or some other third party tool that needs to be installed on the client's machine.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.