Results 1 to 8 of 8

Thread: Why Ajax ???

  1. #1
    Join Date
    Oct 2006
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why Ajax ???

    I have just a silly question??
    Why should someone use Ajax scripts?
    What are the benefits from that?

    For example if i want to load external files(html) in my main page,
    why not to use iframes for example...
    I'm new and want to learn Ajax but i should first find the reason

    Thanx in advance...

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by psilos
    Why should someone use Ajax scripts?
    When it solves a specific problem better than any alternative. Yes, your question was rather open (and a touch vague).

    What are the benefits from that?
    It would vary based on how the technology was applied. It might reduce bandwidth requirements (though not usually by a great deal). It may reduce server processor usage by having to process less data. It may increase perceived responsiveness.

    There are disadvantages, of course. The XMLHttpRequest object is not supported on all browsers, or in all versions of the browsers that do support it. Moreover, ActiveX restrictions may disable it in MSIE, and a lack of scripting support in any browser will do the same[1]. Furthermore, as data won't be available until the response has been received in full, the processing of that data will be delayed on the client (compare to incremental rendering of HTML).

    For example if i want to load external files(html) in my main page,
    why not to use iframes for example...
    Inline frames have better support than AJAX, and should be a consideration. However, a better one would be to process the document on the server first, if necessary, and use links normally to reload the complete document.

    Using AJAX to load complete portions of markup has its own problems. It's pretty much impossible to bookmark a location, navigation controls don't work, the browser history is useless, and search engines won't index the site unless an AJAX-less fallback is provided (but if it is, there's arguably no point in using AJAX, considering the other issues).

    I'm new and want to learn Ajax but i should first find the reason
    Good. Too many bandwagons about these days. Nice to see people not jumping on to them.

    Mike


    [1] The implications of this is that for any critical functionality, a fallback is required. However, that applies to any scripted feature.

  3. #3
    Join Date
    Oct 2006
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    AJAX also allows you to create more application style web pages..

    google maps, gmail, meebo.. they utilize ajax. It allows you to update the page without actually refreshing it.

    Though mwinter is correct about the downfalls. No history, or browser controls...

  4. #4
    Join Date
    Oct 2006
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanx for your answers...
    I'll have in mind.

    Keep up...

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    A great example of something that needs ajax is an html-based chat. You need php/cgi/etc to access the database, and also need it to run in realtime. A constant refresh is annoying and wastes bandwidth. Using ajax, it can run in the background and be fairly seemless.

    Ajax is overused for a lot of things that could easily be done with just javascript or another html alternative. So... don't overuse, but consider in the cases mentinoed above (and other similar ones).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    as a semi experienced web site programmer there are some pro cons

    Pros
    1. Ajax returns the entire html of the page requested as a string makign it easily manipulated with a variety of languages before ever being displayed
    2. allows you to create custom applications with no need to format out put formatting can be performed on the page that displays the result
    3. allows you to ask a browser to search multiple pages return content as string then search strings for requested data without actually requireing the page to load (good for search this site options)

    Cons
    1. Browser support dispite it being 6 years old now the http request is barely supported
    2. relative urls in documents yeild broken information such as images not displaying browser scripts on pages not working correctly and hyperlinks that do not have full url not working
    3. can sometimes be slower for the user because entire page must be returned before any code or display can be executed on it


    the point is there are really good reasons and times to use it and there are other times when it would be more a headache than a help

    thats my spin on the subject

  7. #7
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by ttnnkkrr
    Ajax returns the entire html of the page requested as a string makign it easily manipulated with a variety of languages before ever being displayed
    The same can be said of a regular page. This has nothing to do with AJAX.

    allows you to create custom applications with no need to format out put formatting can be performed on the page that displays the result
    How is this an advantage(or a disavantage)? The formating could just as easily be returned by a new page request. Furthermore, if CSS is used this is never a problem.
    allows you to ask a browser to search multiple pages return content as string then search strings for requested data without actually requireing the page to load (good for search this site options)
    Wrong. Just plain wrong. If the browser is searching the text of each page, then they have downloaded the entire page. This requires the page to load, just not where the user can see it happening.

    Browser support dispite it being 6 years old now the http request is barely supported
    I don't see how this a problem. A regular backup should always be provided. Furthermore, XMLhttprequest has pretty decent browser support.
    relative urls in documents yeild broken information such as images not displaying browser scripts on pages not working correctly and hyperlinks that do not have full url not working
    Ok, I'll semi give you that point. This isn't always a problem, but can be.
    can sometimes be slower for the user because entire page must be returned before any code or display can be executed on it
    If you are loading the entire page then you have completely missed the point of AJAX.
    the point is there are really good reasons and times to use it and there are other times when it would be more a headache than a help
    I agree with that.

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    A great example of something that needs ajax is an html-based chat.
    I wouldn't agree at all. HTTP is simply the wrong protocol for that sort of application. It would be better to use Java (an applet or Web Start application) to implement an IRC-like protocol, where a full-duplex, permanent connection can be established, eliminating the need to poll the server for more data.

    A constant refresh is annoying and wastes bandwidth.
    The constant refresh and wasted bandwidth is still there. Moreover, unless both sides play nice, there'll be closed and reopened connections occuring all the time, which wastes even more bandwidth and overloads the server.

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •