1) Ajax.Updater 将 xmlhttprequest 的返回内容直接绑定页面某个元素中.

JAVASCRIPT:

  1.     1 .  function  getContents()
       
    2 .  {
       
    3. var request_url = “test1.html”;       // 需要获取内容的url
       4. var request_pars = ”;//请求参数
       5.

       
    6. var myAjax = new Ajax.Updater(‘result’, request_url,{ // 将request_url返回内容绑定到id为result的容器中
       7. method     : ‘get’, //HTTP请求的方法,get or post
       8. parameters : request_pars, //请求参数
       9. onFailure  : reportError, //失败的时候调用 reportError 函数
      10. onLoading  : loading, //正在获得内容的时候
      11. onComplete : done     //内容获取完毕的时候
      12. }
    );
      
    13. }

      
    14 .

      
    15 .  function  loading()
      
    16 .  {
      
    17. $(‘loading’).style.display = ‘block’;
      
    18. }

      
    19 .

      
    20 .  function  done()
      
    21 .  {
      
    22. $(‘loading’).style.display = ‘none’;
      
    23. }

      
    24 .

      
    25 .  function  reportError(request)
      
    26 .  {
      
    27. alert(‘Sorry. There was an error.’);
      
    28. }

      
    29 . http: // blog.yening.cn/2006/03/14/46.html