YUI3 IO程序流程问题

发布于 2024-08-21 12:33:12 字数 626 浏览 4 评论 0原文

这也可能与简单的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜灵血窟げ 2024-08-28 12:33:12

是的,按照你的做法,事件是全球性的。但是,您可以传递仅适用于单个 XHR 的配置选项。它应该是这样的:

Y.io(uri + "/" + tgt, { 
                        "on": 
                            {
                              "start": onstart,
                              "complete": changecontent,
                              "end": onend
                            },
                        "context": this
                      });

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:

Y.io(uri + "/" + tgt, { 
                        "on": 
                            {
                              "start": onstart,
                              "complete": changecontent,
                              "end": onend
                            },
                        "context": this
                      });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文