我们如何知道 YUI 中的回调函数传递了哪些参数?

发布于 2024-08-09 01:46:07 字数 456 浏览 1 评论 0原文

来自 http://developer.yahoo.com/yui/docs /YAHOO.util.DataSourceBase.html#method_sendRequest,
您可以看到oCallback是一个具有以下属性的对象文字:

成功
数据准备好时调用的函数。
失败
在响应失败条件下调用的函数。

问题是它没有提到成功和失败回调函数可以使用哪些参数。尽管我们可以使用 firebug/其他工具来找出这一点,但如果文档中提供了此信息,那就更容易了。

在YUI中,有很多时候会用到回调函数。
我的问题是,yui网站上有这条信息吗?如果是的话,它在哪里?

From http://developer.yahoo.com/yui/docs/YAHOO.util.DataSourceBase.html#method_sendRequest,
you can see the oCallback is an object literal with the following properties:

success
The function to call when the data is ready.
failure
The function to call upon a response failure condition.

The problem is that it does not mention what parameters will be available to the success and failure callback functions. Although it's possible for us to use firebug/other tools to find that out, it would be easier if this info is available in the documentation.

In YUI, there are lots of times where callback functions will be used.
My question is that, is this piece of info available in yui website? If yes, where is it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

独行侠 2024-08-16 01:46:07

它在页面上显示您链接到的内容将“传递给回调函数”:

以下参数传递给
回调函数:

  1. oRequest
    与作为 sendRequest 的第一个参数传入的值相同。

  2. oParsedResponse 对象文字
    包含以下属性:

    tId 唯一的交易 ID 号。
    results 模式解析的数据结果。

    error 数据错误时为真。

    cached 返回响应时为 True
    来自数据源缓存。


    模式解析元数据。

  3. oPayload
    与传入的值相同
    oCallback 对象中的参数
    文字。

然而他们没有说这是否会同时影响成功和失败。我想由于第二个参数 oParsedResponse 有一个 error 属性,它也适用于 failure 函数。

唯一可靠的方法是按照您提到的方式对其进行调试。

It says right on the page you linked to what will be "passed to the callback function":

The following arguments are passed to
the callback function:

  1. oRequest
    The same value that was passed in as the first argument to sendRequest.

  2. oParsedResponse An object literal
    containing the following properties:

    tId Unique transaction ID number.
    results Schema-parsed data results.

    error True in cases of data error.

    cached True when response is returned
    from DataSource cache.

    meta
    Schema-parsed meta data.

  3. oPayload The
    same value as was passed in as
    argument in the oCallback object
    literal.

However they don't say if this will be passed to both success and failure. I imagine since the second argument oParsedResponse has an error property that it is applicable to failure functions as well.

The only sure fire way to know is to debug it as you mention.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文