总有人间一两风,填我十万八千梦

jQuery .deferredcatch() 用法 手册 | 示例代码

jQuery开发手册 归档 55℃ 0评论

Description: Add handlers to be called when the Deferred object is rejected.

  • version added: 3.0deferred.catch( failFilter )

    • failFilter
      Type: Function()
      A function that is called when the Deferred is rejected.

deferred.catch( fn ) is an alias to deferred.then( null, fn ). Read its page for more information.

Example:

Since the jQuery.get method returns a jqXHR object, which is derived from a Deferred object, we can rejection handlers using the .catch method.

1
2
3
4
5
6
7
$.get( "test.php" )
.then( function() {
alert( "$.get succeeded" );
} )
.catch( function() {
alert( "$.get failed!" );
} );

转载请注明:悠然品鉴 » jQuery .deferredcatch() 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址