I am likely to need to be adding some AJAX ability to some PHP web site material and I wanted to find out what AJAX libraries folks are using with PHP before I dived in on my own.

Anyone care to comment on what they are using and their experience good or bad with it?

    Personally I considered all the AJAX libraries too heavy weight.

    Bear in mind that the AJAX library is client-side and needs to load into the browser.

    On the server-side, you can use PHP 5.1's json_ functions to spit out json responses - this more or less eliminates the need for anything fancy server-side.

    And client-side, all that's really needed is a few functions for working out what URL to post to and composing HTTP POSTs (using XmlHttpRequest).

    So I just wrote my own. It was dead easy.

    Some tips:

    1. Use JSON, not XML for responses.
    2. Use form-encoded POSTs, not XML for requests
    3. Try to keep it simple
    4. Check that there is no other XHR request already running before starting another.

    Mark

      It really depends what you are after. If you want to add a couple of small tweaks nothing that big. Then I agree with MarkR, most libraries are too heavy going.

      However, if you are implementing something bigger (like i am here) then not using a library would require so much extra developing.

      I would not recommended the libraries that I used in the end in that project.

      From what I've used/seen;

      Prototype - very useful
      script.aculo.us - bloated and a bit bugggy at times
      Yahoo! UI - Looks good but I've not used it much
      ExtJS - VERY powerful but very big and only free for non-profit.

      I've heard good things about JQuery and dojo too but not tried them yet. Also mooFX is a powerful small JavaScript effects library.

      If you want something to help you with the actual PHP and handling requests, this is usful xajax

      So i guess, if I was starting a project now I'd try with Yahoo! UI - unless it was just something small then I'd do it myself.

      ... i'm sure there are more I've forgotten to mention.

        MarkR,

        Coming from a PHP4.x background, I haven't yet made the transition to PHP5 but of course I am looking for an reason or excuse to because I already know that PHP5 brings to the table object oriented techniques and many other advancements.

        What I am curious about is your reference to JSON. Is this in relation to the JSON that is found in the Microsoft AJAX framework formerly codenamed Atlas? I wanted to ask about this because in our field of computer technology there are many abbreviations that can take on different meanings and was not sure if this meant the same thing or not.

          irasmith wrote:

          MarkR,
          What I am curious about is your reference to JSON. Is this in relation to the JSON that is found in the Microsoft AJAX framework formerly codenamed Atlas?

          I'm assuming her is refering to JSON as in the JavaScript Object Notation

          http://www.json.org/

          It's a lightweight method for transferring data. I quite like it.
          PHP5 has build in methods for working with it, however there are plenty of resourced for php4 too, in pear etc.

          edit
          It's got nothing in specific to do with Microsoft AJAX. It is used by many languages.

            dougal85,

            Thanks for the postings on this thread and for the additional information you provided regarding JSON. I was not aware that it was something unto itself and could be used by any others. I have recently taken the step of working on getting up to speed on the Microsoft AJAX framework, which also uses JSON, and had assumed it was a part of the framework they developed, but I was obviously wrong about that assumption.

            I deal in both Microsoft and non-Microsoft technologies such as PHP so for me sometimes it gets a bit confusing on what items stand unto themselves and are able to be wrapped up on multiple technologies. For me, JSON is great because once I have learned it then I can equally apply it in both environments that I work in.

            I have recently become aware that it is being suggested to use JSON in place of XML for AJAX applications because JSON is somewhat faster. I am going to have to dig into this some more because I had always been concerned that XML might slow down AJAX style applications once the datasets that were being sent back as responses got to a certain size.

              Write a Reply...