德$成功参数的jQuery.ajax p $ pcation? [英] Deprecation of success Parameter in jQuery.ajax?

查看:160
本文介绍了德$成功参数的jQuery.ajax p $ pcation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我听说,成功参数在jQuery.ajax功能是去precated。我有没有正确地理解了?还是我missunderstanding什么?

Today I have heard that the success-Parameter in the jQuery.ajax function is deprecated. Have I understood that correctly? Or am i missunderstanding something?

例如,这将不会在今后的工作:

For Example this would not work in the future:

 $.ajax({

            url: 'ax_comment.php',              
            type: 'POST',
            data: 'mode=view&note_id='+noteid+'&open='+open+'&hash='+hash,
            success: function(a) {
            ...

            }   

    });

,我必须用这个?

And i have to use this?

$.ajax({

            url: 'ax_comment.php',

            type: 'POST',
            data: 'mode=view&note_id='+noteid+'&open='+open+'&hash='+hash,
            success: function(a) {
            ...

            }   

    }).done(function(a){.....};

来源: http://api.jquery.com/jQuery.ajax/ (向下滚动到<强>德precation注意)

推荐答案

之间有一个区别:

$.ajax({}).success(function(){...});

$.ajax({
    success: function(){...}
});

第一个是被德precated,第二个是不。

The first one is being deprecated, the second isn't.

因此​​,在未来,你可以做两种:

So in future, you can do either:

$.ajax({}).done(function(){...});

$.ajax({
    success: function(){...}
});

这篇关于德$成功参数的jQuery.ajax p $ pcation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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