德$成功参数的jQuery.ajax p $ pcation? [英] Deprecation of success Parameter in jQuery.ajax?
本文介绍了德$成功参数的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¬e_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¬e_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屋!
查看全文