Linux中国  设为主页
 收藏本站
 
当前位置: > 首页 ->网站设计 ->AJAX教程 ->prototype.js 1.4 原代码阅读
  相关分类: 
AJAX教程
CSS/CSS2
Dreamweaver
Fireworks
Flash
HTML/DHTML
JavaScript
Phososhop
网页制作
  站内搜索: 
热门文章排行
热门文章排行 Ajax实现分页查询(06-04)
prototype.js 1.4 原代码阅读(04-24)
使用AjaxPro开发四级无刷新联动下拉(06-04)
在Struts应用中使用Ajax(04-24)
Ajax:拥抱JSON,让XML走开(04-24)
精采文章排行
精采文章排行 使用AjaxPro开发四级无刷新联动下拉(06-04)
微软Asp.net Ajax 1.0的AutoComplete(06-04)
Ajax实现分页查询(06-04)
Ajax实现不刷屏的前提下实现页面定时(06-04)
Ajax程序设计入门(06-04)
  ·微软Asp.net Ajax 1.0的AutoComplete控件·Ajax实现分页查询·Ajax实现不刷屏的前提下实现页面定时刷新·Ajax程序设计入门·微软的Ajax库客户端Bug总结·利用AJAX和ASP.NET实现简单聊天室 ·利用AJAX技术实现网页无刷新进度条显示·Ajax联动下拉框的实现例子·AJAX如何与后台交互

prototype.js 1.4 原代码阅读

作者:Webmaster   来源:Linux-cn.com   点击:   日期:2007-04-24 [收藏] [投稿]

  IE是否经常中毒?推荐您

    var onComplete = this.options.onComplete || Prototype.emptyFunction;
    this.options.onComplete = (function(transport, object) {
      this.updateContent();
      onComplete(transport, object);
    }).bind(this);

    this.request(url);
  },

  updateContent: function() {
    var receiver = this.responseIsSuccess() ?
      this.containers.success : this.containers.failure;
    var response = this.transport.responseText;

    if (!this.options.evalScripts)
      response = response.stripScripts();

    if (receiver) {
      if (this.options.insertion) {
        new this.options.insertion(receiver, response);
      } else {
        Element.update(receiver, response);
      }
    }

    if (this.responseIsSuccess()) {
      if (this.onComplete)
        setTimeout(this.onComplete.bind(this), 10);
    }
  }
});

Ajax.PeriodicalUpdater = Class.create();
Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
  initialize: function(container, url, options) {
    this.setOptions(options);
    this.onComplete = this.options.onComplete;

    this.frequency = (this.options.frequency || 2);
    this.decay = (this.options.decay || 1);

    this.updater = {};
    this.container = container;
    this.url = url;

    this.start();
  },

  start: function() {
    this.options.onComplete = this.updateComplete.bind(this);
    this.onTimerEvent();
  },

  stop: function() {
    this.updater.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  },

  updateComplete: function(request) {
    if (this.options.decay) {
      this.decay = (request.responseText == this.lastText ?
        this.decay * this.options.decay : 1);

      this.lastText = request.responseText;
    }
    this.timer = setTimeout(this.onTimerEvent.bind(this),
      this.decay * this.frequency * 1000);
  },

  onTimerEvent: function() {
    this.updater = new Ajax.Updater(this.container, this.url, this.options);
  }
});

/**
 * 这个函数就 Ruby 了。我觉得它的作用主要有两个
 * 1.  大概是 document.getElementById(id) 的最简化调用。
 * 比如:$("aaa") 将返回上 aaa 对象



 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<

上一页 1 2 3 4 5 6 7 8 9 10 11 1213 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 下一页

上一篇:prototype.js1.4 版开发者手册   下一篇:prototype.js常用函数及其用法
文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论

   相关文章:
·使用AjaxPro开发四级无刷新联动下拉框

   文章评论:(1条)
  
 请留名: 匿名评论   点击查看所有评论 论坛讨论
 

 声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。