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 版本后才支持。


[quote]
http://www.prototypejs.org/api/ajax/options[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值