« Bindows : object-oriented platform for developing AJAX applications | Main | AJAX Proxy 0.1 released »

XAJAX - Ajax applications with PHP

xajax is an open source PHP class library that allows you to easily create powerful, web-based, Ajax applications using HTML, CSS, JavaScript, and PHP. Applications developed with xajax can asynchronously call server-side PHP functions and update content without reloading the page.

XAJAX is released under LGPL licence, and you can find simple tutorial and good documentation in the official project's website. the latest release is xajax version 0.1 beta4

In short adding XAJAX to your application is simple as it could be done in 7 steps

  • Include the xajax class library:
  • require_once("xajax.inc.php");
  • Instantiate the xajax object:
  • $xajax = new xajax();
  • Register the names of the PHP functions you want to be able to call through xajax:
  • $xajax->registerFunction("myFunction");
  • Write the PHP functions you have registered and use the xajaxResponse object to return XML commands from them:
  • function myFunction($arg) { // do some stuff based on $arg like query data from a database and // put it into a variable like $newContent // Instantiate the xajaxResponse object $objResponse = new xajaxResponse(); // add a command to the response to assign the innerHTML attribute of // the element with id="SomeElementId" to whatever the new content is $objResponse->addAssign("SomeElementId","innerHTML", $newContent); //return the XML response generated by the xajaxResponse object return $objResponse->getXML(); }

  • Before your script sends any output, have xajax handle any requests:


  • $xajax->processRequests();

  • Between yourhtml head tags, tell xajax to generate the necessary JavaScript:


  • $xajax->printJavascript();

  • Call the function from a JavaScript event or function in your application:



  • Bookmark this article at these sites
    Comments
    1

    i need some useful tips and tutorials about ajax

    this is excellent

    i need this type of tutorials

    2

    there is more tutorials coming in the next days, so stay tuned :)

    Post a comment





    (Email will remain hidden)





    Please enter the security code you see here




    Related entries
    Email to a friend
    Email this article to:


    Your email address:


    Message (optional):