Listing 1802
Submitted by phpro.org, 27 November 2008
include 'xajax/xajax_core/xajax.inc.php'; $xajax = new xajax(); /*** Register the function ***/ $xajax->registerFunction("showText"); function showText() { $content = 'XajaX rocks diabolic'; $objResponse = new xajaxResponse(); /*** assign the innerHTML attribute to whatever the new $content ***/ $objResponse->assign("some_div","innerHTML", $content); return $objResponse; } $xajax->processRequest(); /*** the path is relative to the web root mmmk ***/ $xajax_js = $xajax->getJavascript('/xajax'); <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>PHPRO.ORG</title> echo $xajax_js; </head> <body> <button type="button" onclick="xajax_showText(); return true;">Click me</button> <div id="some_div">New text will happen here</div> </body> </html>
