2019独角兽企业重金招聘Python工程师标准>>>

A repository of global listeners notified about every step of Prototype-based Ajax requests
有时候,你需要提供所有的Ajax操作发生页面上通过的Ajax.Request,Ajax.Updater的或Ajax.PeriodicalUpdater通用行为。
例如,您可能希望自动显示指标正在进行时,一个Ajax请求,并隐藏它时都不是。你可能要分解出的异常处理以及在登录页面上自定义时尚的某处。有无数的可能性。
为了实现这一目标, prototype提供Ajax.Responders,它可以让你注册(并且,如果您愿意,后来注销)的反应,这是具有特别的命名方法的对象。这些名字来自一组对应于不同时间点(或成果)的一个Ajax请求的生命周期一般回调。
例如,原型自动注册,保持一个漂亮的变量:Ajax.activeRequestCount一个响应。这意味着,在特定的时间,目前活跃的Ajax请求的数量 - 通过监测他们的onCreate的onComplete事件。此代码是相当简单:
Ajax.Responders.register({   onCreate: function() {     Ajax.activeRequestCount++;   },   onComplete: function() {     Ajax.activeRequestCount--;   } });

Responder callbacks

The callbacks for responders are similar to the callbacks described in the Ajax, but take a different signature. They're invoked with three parameters: the requester object (i.e., the corresponding "instance" of Ajax.Request), the XMLHttpRequest object, and the result of evaluating the X-JSON response header, if any (can be null). They also execute in the context of the responder, bound to the this reference.

  • onCreate: Triggered whenever a requester object from the Ajax namespace is created, after its parameters are adjusted and before its XHR connection is opened. This takes two arguments: the requester object and the underlying XHR object.
  • onUninitialized (Not guaranteed): Invoked just after the XHR object is created.
  • onLoading (Not guaranteed): Triggered when the underlying XHR object is being setup, and its connection opened.
  • onLoaded (Not guaranteed): Triggered once the underlying XHR object is setup, the connection is open, and it is ready to send its actual request.
  • onInteractive (Not guaranteed): Triggered whenever the requester receives a part of the response (but not the final part), should it be sent in several packets.
  • onException: Triggered whenever an XHR error arises. Has a custom signature: the first argument is the requester (i.e. an Ajax.Request instance), and the second is the exception object.
  • onComplete: Triggered at the very end of a request's life-cycle, after the request completes, status-specific callbacks are called, and possible automatic behaviors are processed. Guaranteed to run regardless of what happened during the request.
Prototype

转载于:https://my.oschina.net/u/617021/blog/71467

Ajax.Responders相关推荐

  1. Ajax (部分二:prototype.js代码)总结页面向后台传Form值、单个值和后台向前台传一个或是一组值...

    2019独角兽企业重金招聘Python工程师标准>>> 附录prototype.js的代码: Prototype = {Version: '1.5.1_rc4',Browser: { ...

  2. onuninitialized和ajax,12.3 Prototype对Ajax的支持

    12.3  Prototype对Ajax的支持 Prototype为Ajax开发提供了有力的支持,其中主要包括Ajax.Request.Ajax.Response.下面将对这两个核心支持进行讲解. ( ...

  3. Ajax.Request

    Ajax.Request(url,{method:method,parameters:para,postBody:xmlString,asynchronous:true,setRequestHeade ...

  4. ajax prototype框架之Ajax.Request 类

    href="css.css" type="text/css" rel="stylesheet" /> 使用 Ajax.Request ...

  5. prototype.js 1.4版开发者手册

    prototype.js是什么? 万一你没有使用过大名鼎鼎的prototype.js,那么让我来告诉你,prototype.js是由Sam Stephenson写的一个javascript类库.这个构 ...

  6. 转载:Prototype.js的中文使用手册

    转载自:http://thinhunan.cnblogs.com/archive/2006/04/01/DeveloperNotesForPrototype.html 转载仅为翻阅学习方便.感谢原文作 ...

  7. property.js

    Code *********************************************** property.js实例详解(一) **************************** ...

  8. prototype.js开发者手册

    prototype.js开发者手册 对应版本1.4.0 original article by sp('Sergio Pereira') Sergio Pereira last update: Mar ...

  9. prototype.js详解

    prototype.js是什么? 万一你没有使用过大名鼎鼎的prototype.js,那么让我来告诉你,prototype.js是由Sam Stephenson写的一个javascript类库.这个构 ...

最新文章

  1. android动态创建arraylist,Android:二维ArrayList帮助
  2. 使用jq.lazyload.js,解决设置loading图片的问题
  3. Nova计算节点安装配置
  4. .NET Core开发日志——Runtime IDentifier
  5. 数字基带传输学习笔记00引言
  6. html文件设置ftp6,vsftp的安装与配置
  7. 《Python Cookbook 3rd》笔记(2.13):字符串对齐
  8. python 工程结构加固_[原创]某企业级加固[四代壳]VMP解释执行+指令还原
  9. 干不过微信,又抢钉钉地盘!中移动砸下 8400 万重做飞信
  10. mysql什么是表的并的关系_MySQL表与表的关系
  11. fckeditor java 使用方法_FCKeditor使用说明
  12. GreenSock GSAP 3.0 最新版 所有内容创建于2020年4月4日
  13. 外卖分销分佣小程序外卖cps小程序返利系统源码分享
  14. 更改C盘用户目录下的文件夹名称
  15. HEG安装教程(windows平台)
  16. 深度学习从入门到精通——生成对抗网络原理
  17. vcruntime140_1.dll 丢失的解决办法
  18. Houdini 节点
  19. 缺乏技术专利支撑的小米还能走多远
  20. 潮位调和分析工具学习(2)——使用T_tide时遇到的问题

热门文章

  1. idea怎么拉不同的git分支_idea中git分支、合并与使用
  2. android日历信息获取错误,android – 从日历中获取事件
  3. 在wamp里面配置feehicms
  4. Learning to Reconstruct 3D Human Pose and Shape via Model-fitting in the Loop
  5. 字节跳动 | 机器学习与推荐算法工程师培养计划
  6. 文末福利 | 学习如何构建行业知识图谱(以医疗行业为例)
  7. 什么叫百度下拉框?除了百度下拉还有哪些下拉词框可以优化?
  8. r语言集合补集_R语言之数据处理(二)
  9. 华为认证hcia含金量_【华为认证】HCIA-DATACOM史上最全精选题库(附答案解析)...
  10. 水准网测量平差matlab_1K417012场区控制测量