Using xajax in a PHP script xajax is designed to be extremely easy to implement in both existing web applications as well as new projects. You can add the power of xajax to nearly any PHP script in seven easy steps: 1. Include the xajax class library: require_once("xajax.inc.php"); 2. Instantiate the xajax object: $xajax = new xajax(); 3. Register the names of the PHP functions you want to be able to call through xajax: $xajax->registerFunction("myFunction"); 4. 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 xajaxResponse object return $objResponse; } 5. Before your script sends any output, have xajax handle any requests: $xajax->processRequests(); 6. Between your tags, tell xajax to generate the necessary JavaScript: printJavascript(); ?> 7. Call the function from a JavaScript event or function in your application (you must change SomeArgument into a real variable, a string, etc.--some argument is required): That's it. xajax takes care of most everything else. Your biggest task is writing the PHP functions and returning xajax XML responses from them-- which is made extremely easy by the xajaxResponse class. reference link http://xajaxproject.org/wiki/Tutorials:Learn_xajax_in_10_Minutes
|
My Blog Title
|