YUI3 IO程序流程问题
这也可能与简单的 Javascript 相关,但这里是 IO 的链接,以防万一: YUI3 IO< /a>
我创建了一个 YUI 实例,并使用 io 函数从服务器检索数据。
YUI().use('event', 'node', 'io', function(Y) {
Y.on('io:start', onstart, this, true);
Y.on('io:success', changecontent, this);
Y.on('io:end', onend, this, true);
// irrelevant code has been omitted
function loadpage(e) {
var request = Y.io(uri+"/"+tgt);
}
});
这是否意味着如果我在任何时候在开始/成功/结束时使用 Y.io ,它都会分别调用 onstart/changecontent/end ?
我想对服务器进行多次调用,但有不同的函数来处理每次调用的结果。我该怎么做呢?
谢谢。
This may also be simple Javascript related but here is the link to IO just in case: YUI3 IO
I have a YUI instance created and am using the io function to retrieve data from the server.
YUI().use('event', 'node', 'io', function(Y) {
Y.on('io:start', onstart, this, true);
Y.on('io:success', changecontent, this);
Y.on('io:end', onend, this, true);
// irrelevant code has been omitted
function loadpage(e) {
var request = Y.io(uri+"/"+tgt);
}
});
Does this mean that if I, at any time, use Y.io on start/success/end it will call onstart/changecontent/end respectively?
I want to make multiple calls to the server but have different functions to handle the results from each call. How would I go about doing this?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,按照你的做法,事件是全球性的。但是,您可以传递仅适用于单个 XHR 的配置选项。它应该是这样的:
Yes, the way you're doing it the events are global. However, you can pass a config option that only applies for a single XHR. It should be something like: