`
tom_cjp
  • 浏览: 42363 次
  • 性别: Icon_minigender_1
  • 来自: 温州
文章分类
社区版块
存档分类
最新评论

onLoading PK onCreate [ prototype ]

 
阅读更多
场景: 禁止鼠标点击触发2次ajax请求。 而采取在ajax开始前,禁用按钮, 完成后再启用。

选手介绍:
1.onLoading: Triggered when the underlying XHR object is being setup, and its connection opened.

2.onCreate:  when the Ajax.Request object is initialized. This is after the parameters and the URL have been processed, but before first using the methods of the XHR object.

分析:
从介绍中可以知道 如果禁用按钮的代码在onLoading(传统做法)里, 此时连接已经开启。实际中在1秒间的快速点击是会引起两次ajax请求的。但onCreate这哥们,在整个服务前,就能做到完美实现需求了。

注意:
onCreate方法 在 1.5.1 版本后才支持。


引用

http://www.prototypejs.org/api/ajax/options


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics