function smarty_function_ajaxcall($params, &$smarty) { require_once 'HTML/AJAX/Helper.php'; $target = @$params['target']; $call = @$params['call']; $type = !is_null(@$params['type']) ? @$params['type'] : 'replace'; $ajaxHelper = new HTML_AJAX_Helper(); $ajaxHelper->serverUrl = '/AJAX/server.php'; if (@isset($params['stubs'])) { $stubs = split(',', $params['stubs']); foreach ($stubs as $stub) { $ajaxHelper->stubs[] = $stub; } } if (@(!$smarty->hasJSlibs)) { echo $ajaxHelper->setupAJAX(); } $smarty->hasJSlibs = true; if (@is_null($params['loadJS'])) { // echo $ajaxHelper->loadingMessage ( "Waiting on the Server ...", null, 'position: absolute; top: 0; left: 0; display: none;' ); echo $ajaxHelper->updateElement($params['target'], $params['call'], $type, true); echo '<div id="' . $target . '"> </div>'; } }
require_once 'HTML/AJAX/Helper.php'; // create an instance and set the server url $ajaxHelper = new HTML_AJAX_Helper(); $ajaxHelper->serverUrl = 'auto_server.php'; $ajaxHelper->jsLibraries[] = 'customLib'; ?> <html> <head> <?php // output a javascript neded to setup HTML_AJAX // by default this is all the libraries shipped with HTML_AJAX, take a look at $ajaxHelper->jsLibraries to edit the list echo $ajaxHelper->setupAJAX(); ?> </head> <body> <?php // output a custom loading message echo $ajaxHelper->loadingMessage("Waiting on the Server ..."); ?> <div id="updateTarget">I'm an update Target</div> <?php // update the element using ajax echo $ajaxHelper->updateElement('updateTarget', array('test', 'echo_string', 'Some text to echo'), 'replace', true); ?> </body> </html> <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */