#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    19
    Rep Power
    0

    Talking Ajax vs javascript


    Hi guys. I'm just getting started with ajax to use with PHP.

    i'm reading a book that begins with some examples of where ajax can be used. One of these examples was when you select a country in a form, ajax dynamically returns the areas of that country in the next box. This could obviously be done in javacript alone so what is the difference and benefits of using ajax for this particular example and similar situations??

    cheers

    Anthony
  2. #2
  3. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    Fetching only the necessary content?

    If there's a lot of content you would be fetching it from php in the first place and printing it onto the page for the javascript to work. In some cases that can be an awful lot of data. In some cases it may be fetching it off a different site where it's split into seperate sections so programmatically it would be an advantage.

    fwiw, I think ajax is overused, i've seen entire sites written in ajax and that's ridiculous, you lose the ability to link to a specific page and you completely cut out older browsers that don't do ajax.

    Use ajax where it is the best solution to a problem and nowhere else.
  4. #3
  5. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    The J in AJAX stands for Javascript. There's no difference.

    -Simon

    Comments on this post

    • LinuxPenguin disagrees : (0) You've completely missed the point of the post. It wasn't a straight off comparison, it was 'why use ajax over straight javascript'
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    19
    Rep Power
    0

    Talking re


    Hi guys thanks for your replies

    Linux Penguin - yea that's pretty much what I thought. I wouldn't consider doing whole sites with ajax. I'm just looking at for improving a few UI features

    SImon - There's no difference?? I knew it stood for javascript but I thought it combines javacript and XML to enhance javascripts abilities. E.g. Is this ajax form possible in javascript?? never tried it:

    http://ajaxphp.packtpub.com/ajax/quickstart/

    cheers
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Posts
    2,270
    Rep Power
    1737
    Originally Posted by lsals
    I knew it stood for javascript but I thought it combines javacript and XML to enhance javascripts abilities.
    AJAX doesn't enhance Javascript. It relies on it. Javascript is a client side technology. It is purely run on the browser. But a lot of data and logic is on the server. AJAX can be thought of as interface between the technologies.
  10. #6
  11. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0
    AJAX just uses javascript to communicate with the server in the form of XML. That's all. There's no magical difference between javascript and AJAX, AJAX is an implementation of javascript.

    As LP said, it's great for making sites a bit more responsive. Common examples include filling in drop down sub menus based on the users choice. For example, "please select which country you live in" -> "and the city". The non ajax-y way would be to either load all possible citys for all countries (large and slow), and swap between them with something like an onSelect. Using ajax you can wait for the user to select the country, and bounce back to the server to get the city list, and then swap it in. Should send less data to the user, and be a bit more responsive.

    --Simon
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    19
    Rep Power
    0

    Talking re


    Hi guys. thanks alot for your responses. I think I get what Ajax is all about now.

    cheers

IMN logo majestic logo threadwatch logo seochat tools logo