在ajax .done中为函数提供了哪些参数? [英] What arguments are supplied to the function inside an ajax .done?

查看:238
本文介绍了在ajax .done中为函数提供了哪些参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下内容:

    $.ajax(link.href,
    {
        cache: false,
        dataType: 'html'
    })
        .done(onDialogDone)
        .fail(onDialogFail);

这样可以正常工作并调用onDialogDone。但是,我希望看到哪些参数提供给onDialogDone,以及我期望在onDialogFail中看到什么。

This works fine and onDialogDone is called. However what arguments should I expect to see supplied to the onDialogDone and what should I expect to see for onDialogFail.

我问的原因是因为我使用的是typescript,我想在定义onDialogDone和onDialogFail时提供正确的参数。

The reason I am asking is because I use typescript and I want to supply the correct arguments when I define my onDialogDone and onDialogFail.

推荐答案

.done() .fail()与相应的成功的参数相同:错误: $。ajax() 功能,即:

The arguments for .done() and .fail() are the same as the arguments for the corresponding success: and error: parameters for the $.ajax() function, namely:

.done( function(data, textStatus, jqXHR) { ... } );

.fail( function(jqXHR, textStatus, errorThrown) { ... } );

出于打字稿的目的, textStatus errorThrown 是字符串, jqXHR 对象,以及 data 取决于远程服务器发送给你的东西。

For the purposes of typescript, textStatus and errorThrown are strings, jqXHR is an Object, and data depends on what the remote server sends you.

这篇关于在ajax .done中为函数提供了哪些参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆