; <script type="text/javascript"src="server.php?client=all"></script> <div id="target">I''m the target</div>
<script type="text/javascript"> HTML_AJAX.replace(''target'', ''testdata.php''); </script>
</body> </html> testdata.php 这是个很简单的php程序,取到分页数据并输出html
PLAIN TEXT PHP: <?php require_once''Pager/Pager.php''; $data=range(1,100);//an array of data to paginate $pager_params=array( ''mode'' =>''Sliding'', ''append'' =>false, //don''t append the GET parameters to the url ''path'' =>'''', ''fileName''=>''javascript:HTML_AJAX.replace(\''target\'',\''testdata.php?pageID=%d\'');'', //Pager replaces "%d" with the page number... ''perPage'' =>10,//show 10 items per page ''delta'' =>1, ''itemData''=>$data, ); $pager= & Pager::factory($pager_params); $n_pages=$pager->numPages(); $links=$pager->getLinks(); echo''<p>This container is loaded with an AJAX call</p>''; echo''<p><span class="datetime">DateTime: ''.date(''Y-m-d H:i:s'').''</span></p>''; echo''<h3>Page ''.$pager->getCurrentPageId().''</h3>''; foreach($pager->getPageData()as$item){ echo''Item ''.$item.''<br />''; } echo''<hr />''.$pager->links; ?> 最后,贴上幕后工作者server.php的代码 用HTML_AJAX_Server来处理ajax这些烦心事吧
PLAIN TEXT PHP: <?php include''HTML/AJAX/Server.php''; $server=newHTML_AJAX_Server(); $server->handleRequest(); ?> |