Slashdot Mirror


PHP & AJAX Presentation Online

the.admin.man writes "There's been quite a bit of buzz around using PHP as a backend to AJAX-based web applications (the same development methodology on which some Google applications), lately, particularly after the release of JPSpan, a framework that helps building XML-based interfaces between Javascript and PHP apps. Just yesterday, Joshua Eichorn gave a presentation to the Arizona PHP Group on developing AJAX applications for PHP--he's posted the slides online, and will give his presentation again through a free webcast hosted by php|architect."

33 comments

  1. What is this... by __aaclcg7560 · · Score: 0, Redundant

    I got this crazy idea about becoming a web developer and I been learning all the individual technologies to put stuff together. But it seems like I'm missing the grand overview something that would tie everything together. Is AJAX the silver bullet I can use to build all those awesome Google-like websites? Or is it more alphabet soup that I'll probably end up throwing out later after I bought all the overpriced books?

    1. Re:What is this... by hhlost · · Score: 3, Informative

      Well... Funny thing, I was researching AJAX earlier today. It certainly looks cool, particualry if you read this article: http://www.adaptivepath.com/publications/essays/ar chives/000385.php that's linked in the Wikipedia article and look at the cool stuff that Google's been doing with it. But I'm not convinced that it's far enough along for companies that don't have a ton Phds on staff to jump into... Has anyone here implemeted AJAX?

    2. Re:What is this... by __aaclcg7560 · · Score: 2, Insightful

      After reading the article, it sounds like they are using a Javascript processor on the client side instead of using a PHP processor on the server side. Whether you use AJAX is really dependent on whether you believe processing should be done on the server, client or both. This is more alphabet soup. I'll stick with PHP on the server and Javascript on the client for now.

    3. Re:What is this... by chris_mahan · · Score: 2, Informative

      I have, on private sites, and I use xmlrpc rather than xml+xslt, but otherwise the same. I use virtual cowboys js lib for that. on the client, in ASP, i use the lib I worked over from Carter-Todd. In php, i don't, and I use Python's xmlrpclib to test the client-side stuff. I do database updates, retrieve values, settings, and html blocks (escape/unscape is your friend, since xmlrpc can't pass xml docs)

      Should also say that it's not easy, but it's doable. Use firefox + webdeveloper toobar by Chris Pederick to get info on the page, and check that javascript console for error messages.

      Finally, writing down on old fashioned paper what the beast will look like is invaluable.

      --

      "Piter, too, is dead."

    4. Re:What is this... by Anonymous Coward · · Score: 0

      plain and simple, its just another snazzy fucking name..

      All it is, is a mix of using javascript event functions to make serverside calls with php without a page refresh. Its as simple as that. OnClick, Onload, Onblur, etc.. u call a JS function that then relays to a php page, based on current page varibles that you can work with.

      All you need is the deafult lines of JS code that make the actual function calls. They are very small functions.

      The JS function that you call that loads the php server fragment usualy has only 2 parameters that you need, 1. The name of the page you are calling. and 2. The id you have designated to return the information from the call.

      To me this ajax name is the next xml name clusterfuck. It has a million different meanings and can be used with a million different languages, and is touted as the next best thing, but in the end no one knows what the hell it means..

    5. Re:What is this... by paRcat · · Score: 2, Interesting

      Yeah, I've implememted it on our intranet for certain types of reporting.

      Personally, I love it. Once I figured it out, it struck me at how clunky my old code was. There are many areas where I went through WAY too much trouble putting things into JS arrays and whatnot because I didn't want the visitor to have to refresh. But now I can use common PHP code to get the data when I need it.

      The one thing I will say is that there seems to be a lot of needlessly complicated example code out there. I've implemented the entire system in 3 JS functions, and it works flawlessly. I'd post it here, but somehow I feel I'd either be looked at as a karma whore or a redundant post. :/

      Either way, you should try it. It's not that hard, and the results are definitely useful.

    6. Re:What is this... by Zachary+Kessin · · Score: 0, Redundant

      Yes, actually not only have I implemented it, I've built a toolkit to automate it. (I hate doing boring reptative work). The XAB toolkit can build an Ajax based database application (or at least most of one) for you with automaticly generated PHP, XML and Javascript. It uses Mozilla's SOAPCall functionality so for right now it won't work in IE, but I expect to fix that at some point.

      There is also a program in there to take a PHP class and automaticly generate javascript code to wrap it.

      I have also set up an Ajax Wiki.

      --
      Erlang Developer and podcaster
    7. Re:What is this... by hoggoth · · Score: 1

      There is no silver bullet. To make a non-trivial web application you will need to write in the following languages/technologies:

      SQL for the database.
      A server-side application language like PHP, Coldfusion, Java/JSP, Ruby, etc.
      HTML for the client-side layout.
      Javascript for the client-side application program.

      AJAX just refers to a Javascript programming technique.

      > I got this crazy idea about becoming a web developer

      I got this sane idea to STOP being a web developer... you know, what with having to pay rent and buy food and stuff...

      --
      - For the complete works of Shakespeare: cat /dev/random (may take some time)
    8. Re:What is this... by Anonymous Coward · · Score: 0

      Nobody will think you are a karam whore or a redundant post. You don't have to post the code but don't use a lame excuse.

  2. Most likely the... by ciroknight · · Score: 3, Informative

    ...latter. Ajax, though neat, isn't going to change the world, but it will make a lot of websites a lot easier to use.

    Generally, all Ajax does is replace the constant "page jumping" that occurs with past server-client web pages. For example, when you are looking for something, and you have to jump across a hundred pages to find it, or when you're filling out a form, it doesn't jump to a new page for "confirmation".

    I'm sure there will be a lot of other great uses for it as well. Does anyone remember games like "Stellar Crisis"? I'm sure it'd stand to gain a LOT from Ajax.

    --
    "Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is." G.W.Bush
    1. Re:Most likely the... by vcv · · Score: 2, Insightful

      And it can save a LOT of bandwidth. However, writing for it is currently a nightmare for the most part.

    2. Re:Most likely the... by Zachary+Kessin · · Score: 2, Informative

      Check out my XAB toolkit Its a tool to make it easier. It uses code generation to build a lot of code for you so that you can do the interesting bits and let the computer do the dull stuff.

      --
      Erlang Developer and podcaster
  3. object oriented programming in javascript by oever · · Score: 4, Interesting

    I've been working in a prototype AJAX application for a while now and it really is a very nice idea. One cool thing that I discovered, is that javascript isn't the terrible language I always thought it was. Granted, it's not very sophisticated, but you can actually do OO programming in javascript. Notably, you can create classes, use event listeners on these classes.

    However, what I'd really like to see is a good javascript library that acts as an abstraction layer that removes the browser differences in javascript, css and html support.

    --
    DNA is the ultimate spaghetti code.
    1. Re:object oriented programming in javascript by Anonymous Coward · · Score: 1, Insightful

      Oh yes, JS is actually a *really* cool language, right up there with the "academic" languages. In fact it's very much like Self, which is a prototype-based language. A single concept implemented cleanly from top to bottom.

      Somewhere on there net there's a JS program which makes JS work like Ruby (blocks, iterators, etc).

      Too bad JS is trapped in the browser like that, having to deal with the outside world via DOMs and documents and junk like that.

  4. AJAX makes more sense with Nevow by Anonymous Coward · · Score: 1, Informative

    Check the Python web framework from www.nevow.org (requires Twisted. It makes much more sense to implement Nevow's LivePage (which is basically the same thing as so-called AJAX approach) with Twisted Python webapps -- Twisted webapp is created once and then, runs non-stop at the server side. PHP scripts are executed on each request (so, objects are created every time you click anywhere), this gives you less possibilities of exploiting "live web page" approach.

    Or, in other words: if you want your web pages to be live, make sure your webapp is also running in realtime (and is not just a script, executed on each request).

  5. Why PHP? by Anonymous Coward · · Score: 2, Informative

    You can do "ajax" with any server-side technology, the key to ajax is doing HTTP calls via javascript instead of whenever the user clicks a link, so who cares what's on the other side?

    Of course I have to plug Ruby on Rails here.. adding dynamic stuff to your app is just 1 or 2 lines of code. This is how it should be!

    PHP is fine too, if you bill by the hour. ;-)

  6. slides/show by lucidvein · · Score: 1

    I had to go to the fellow's blog to find the slides... http://blog.joshuaeichorn.com/slides/Building_Rich _Web_Applications_With_AJAX/. Kind of buried the lead there...

    And so, a month from now, I can watch the presentation? Hmm, Let me add that to my calendar. Why so far in advance?

    --

    "I have a cunning plan..."

    1. Re:slides/show by Anonymous Coward · · Score: 0

      Because we wanted to have enough time for interested people to find out about it. After all the php|architect guys just called me yesterday.

      I also have a couple introductory articles on my blog you guys might find useful in my AJAX category

      -joshua eichorn
  7. Rephrase your question, please :^) by Anonymous Coward · · Score: 0

    "Was web terribly broken from the start?"

    I believe it was okay by the time it was created.

    "Is web terribly broken now?"

    Perhaps.

    "Is AJAX a way to fix that breakage a bit?"

    Perhaps! Chances are it introduces more, but in fact, this is a pretty slick way to turn "one request, one web page" into "one request, one web page, lot of action later".

    Right now, you don't have anything better (and, cross-browser, if we have just IE & Firefox in mind).

    And, books? I don't think, that there are any... it's too fresh.

    "Is AJAX the silver bullet (...) ?"

    I believe it is. Only that you need to have a good library at both sides to nicely wrap it.

  8. Doing this for years now by Flammon · · Score: 0

    I've been using this technique for years - since 1998 I believe. The first application that I used it on was a kiosk. The kiosk application was done using IE and some ActiveX controls to read magcard from a reader and print to a serial port. Well, every time the page loaded, these ActiveX controls would take an eternity to init the serials ports and so on. So I put all that code into another hidden frame and used this hidden frame to control the display frame. Works great.

    1. Re:Doing this for years now by Anonymous Coward · · Score: 1, Insightful
      I've been using this technique for years - since 1998 I believe. The first application that I used it on was a kiosk. The kiosk application was done using IE and some ActiveX controls to read magcard from a reader and print to a serial port. Well, every time the page loaded, these ActiveX controls would take an eternity to init the serials ports and so on. So I put all that code into another hidden frame and used this hidden frame to control the display frame. Works great.

      So except for the lack of XML or remote server calls that was just like AJAX?

    2. Re:Doing this for years now by Anonymous Coward · · Score: 0

      Yeah, that is exactly the same thing as AJAX, except of course without the XML, or the javascript.

    3. Re:Doing this for years now by sydney094 · · Score: 1

      Agreed... You can use callback IFRAMES to generate a lot of the same functionality as AJAX. You don't actually need the XML results to do the work, hidden iframes work just as well. They can also be more flexible, since you can embed javascript in the hidden frame to make a callback to the parent. The only down side is if the user is too "click-happy". You may not have time to load the hidden iframe's page...

      I don't know exactly if/how AJAX style XML requests get around this.

      --
      "If we knew what we were doing, it wouldn't be called research." - Einstein
    4. Re:Doing this for years now by tigersha · · Score: 1

      So AJAX - JA - X = A? So the guy wrote A Application. At least he removed an acronym, except now the grammar is wrong.

      --
      The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
  9. Use the library that Rails uses. by Paradox · · Score: 4, Informative

    It's called Prototype, and it's available right here.

    It's very well written, gets a lot of maintenance, and even has some eye candy as a bonus.

    --
    Slashdot. It's Not For Common Sense
    1. Re:Use the library that Rails uses. by oever · · Score: 1

      Thanks for the pointer. The single js file in the project has some useful classes. Unfortunately, there's no documentation of what these classes should do at all. This makes it very timeconsuming to even find out if what you want is in there, let alone find out how to use it.

      --
      DNA is the ultimate spaghetti code.
  10. For the love of all that's holy by weeksie · · Score: 2, Insightful

    For the love of all that's holy and good can we please stop calling it Ajax? It's one bloody JavaScript object. Great that it's being used more often, good on Google for getting it out there and popular but it just doesn't do the technology any good to overhype it. If we are going to call it something cute it should be Greasemonkey because monkeys and grease are cool.

    In any case I've built a greasy little forum app that uses the shit out of XmlHttpRequest and it doesn't really require any special toolkits. It's just a matter of making calls to the server with JavaScript and using the response to populate your page (generally with .innerHTML = whatever). World changing or not it's more fun than a car full of fat people

    Check it out if you like http://beta.twelvestone.com/forum

    1. Re:For the love of all that's holy by Paradox · · Score: 1
      For the love of all that's holy and good can we please stop calling it Ajax?


      The fact that you're even saying this in response to a slashdot article posting means it's far too late.

      Roll with it. It's not so bad a name.
      --
      Slashdot. It's Not For Common Sense
    2. Re:For the love of all that's holy by weeksie · · Score: 1

      I guess that's a good a point as any :)

      it's just frustrating when people come out with all of these "toolkits" for this and that and do the overnight expert thing for tech that's pretty damned old anyway. ahhhh well.

  11. This is true. by Paradox · · Score: 1

    Prototype needs docmentation badly. Probably the best way for you to learn it is to email the author and ask for some pointers.

    You can also go to some Ajax-Enabled rails sites and see their source.

    It's unfortunate, but that's just the way a lot of web development is these days. People just don't document they way they do in other circles.

    --
    Slashdot. It's Not For Common Sense
    1. Re:This is true. by Anonymous Coward · · Score: 0

      Prototype needs docmentation badly.

      I found it to be self explanatory.

  12. I dunno about throwing it out. by Paradox · · Score: 1

    Ajax is just using XMLHttpRequest to get object and using Javascript DOM to update the page accordingly.

    There are various ways to accomplish this, depending on what toolkits you use to make your website. But certainly, an Ajax'd web application feels a lot smoother and more friendly than a non-Ajax'd application.

    It's especially useful when editing lists, tables, or groups.

    --
    Slashdot. It's Not For Common Sense