ajax
非常酷的窗口效果,基于prototype.js开发出来的ajax经典作品。说不定会应用在以后的项目中。

网址:http://prototype-window.xilinus.com/themes.html
各式各样的ajax技术
Posted in AJAX on 2007/03/02 / 评论(0) »
          推荐一个国外的网站,收集了很多ajax技术。http://www.miniajax.com/
    原理:通过在dom创建script tag,引入外部php文件,php文件生成javascript内容。
  代码
1.page1.php

<?php

$html = '<b>This content came from our Ajax Engine</b>';

?>

div = document.getElementById('contentdiv');
div.innerHTML = '<?php echo $html; ?>';



2.engine.js

// Get base url
url = document.location.href;
xend = url.lastIndexOf("/") + 1;
var base_url = url.substring(0, xend);

function ajax_do (url) {
       // Does URL begin with http?
       if (url.substring(0, 4) != 'http') {
               url = base_url + url;
       }

       // Create new JS element
       var jsel = document.createElement('SCRIPT');
       jsel.type = 'text/javascript';
       jsel.src = url;

       // Append JS element (therefore executing the 'AJAX' call)
       document.body.appendChild (jsel);
}




3.index.htm

<html>
       <head>
               <title>Demo 1 - The Basic's</title>

               <script type="text/javascript" src="engine.js"></script>        
       </head>

       <body>
               <div id="contentdiv">

               </div>

               <input type="button" onclick="ajax_do ('page1.php');" value="Get content" />
       </body>
</html>





最后注意:Ie浏览器的安全级别要 小于High
HTML_AJAX 使用
Posted in AJAX on 2006/10/12 / 评论(0) »
PEAR 库新类 html_ajax 下载地址http://pear.php.net/package/HTML_AJAX

手册地址: http://www.azphp.org/files/HTML_AJAX.html

使用起来不是很简单.特别是将php类注册成js,成为ajax的扩展.

使用步骤:

1.写PHP类,由调用.

server2.php 如下

require_once 'HTML/AJAX/Server.php';
//php类
class example {
   function rot13($input) {
       return str_rot13($input);
   }

   function upperCase($input) {
       return strToUpper($input);
   }
}

$server = new HTML_AJAX_Server();

// upperCase will export as uppercase in php4 and upperCase in php5
$server->registerClass(new example());

// works in both php4 and 5 plus doing class name aliasing
$server->registerClass(new example(),'example2',array('rot13','upperCase'));

$server->handleRequest();
?>

2.通过javascript 引用返回.



3.在页面上由触发机制应用js

例如:rot13 input

upperCase input

分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]