AJAX for dummies thread

Discussion in 'JavaScript' started by 123GoToAndPlay, Aug 17, 2006.

  1. #1
    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??
     
    123GoToAndPlay, Aug 17, 2006 IP
  2. afactory

    afactory Well-Known Member

    Messages:
    336
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    afactory, Aug 17, 2006 IP
    eXe likes this.
  3. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    tx, afactory.

    That's a lot of code to say hello ;)
     
    123GoToAndPlay, Aug 17, 2006 IP
  4. afactory

    afactory Well-Known Member

    Messages:
    336
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Yeap, but AJAX applications looks pretty nice ;) after all the code will be done.
     
    afactory, Aug 17, 2006 IP
  5. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    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 or here.
     
    phper, Aug 17, 2006 IP
  6. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    @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 is quit clear for a beginner
     
    123GoToAndPlay, Aug 18, 2006 IP
  7. RyanSmith345

    RyanSmith345 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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.
     
    RyanSmith345, Aug 18, 2006 IP
  8. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    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>
    
    Code (markup):

    Questions:
    - Does this qualify as an AJAX appli??
    - Is this a right use of AJAX??

    Regards
     
    123GoToAndPlay, Aug 20, 2006 IP
  9. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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
     
    123GoToAndPlay, Aug 20, 2006 IP
  10. RyanSmith345

    RyanSmith345 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    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.
     
    RyanSmith345, Aug 29, 2006 IP
  11. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #11
    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.
     
    phper, Aug 29, 2006 IP
  12. Alis

    Alis Peon

    Messages:
    1,787
    Likes Received:
    159
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Ajax is old you know :) There is a better technology then ajax it just replaced it ...
     
    Alis, Aug 29, 2006 IP
  13. RyanSmith345

    RyanSmith345 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    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.
     
    RyanSmith345, Aug 30, 2006 IP