setting.callback.onAsyncError.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span class="path">setting.callback.</span>onAsyncError</h2>
  4. <h2><span>Function(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown)</span>&nbsp;</h2>
  5. <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
  6. <div class="desc">
  7. <p></p>
  8. <div class="longdesc">
  9. <p>用于捕获异步加载出现异常错误的事件回调函数</p>
  10. <p class="highlight_red">如果设置了 setting.callback.beforeAsync 方法,且返回 false,将无法触发 onAsyncSuccess / onAsyncError 事件回调函数。</p>
  11. <p>默认值:null</p>
  12. </div>
  13. </div>
  14. <h3>Function 参数说明</h3>
  15. <div class="desc">
  16. <h4><b>event</b><span>js event 对象</span></h4>
  17. <p>标准的 js event 对象</p>
  18. <h4 class="topLine"><b>treeId</b><span>String</span></h4>
  19. <p>对应 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
  20. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  21. <p>进行异步加载的父节点 JSON 数据对象</p>
  22. <p class="highlight_red">针对根进行异步加载时,treeNode = null</p>
  23. <h4 class="topLine"><b>XMLHttpRequest</b><span>String</span></h4>
  24. <p>标准 XMLHttpRequest 对象,请参考 JQuery API 文档。</p>
  25. <h4 class="topLine"><b>textStatus</b><span>String</span></h4>
  26. <p>请求状态:success,error,请参考 JQuery API 文档。</p>
  27. <h4 class="topLine"><b>errorThrown</b><span>String</span></h4>
  28. <p>errorThrown 只有当异常发生时才会被传递,请参考 JQuery API 文档。</p>
  29. </div>
  30. <h3>setting & function 举例</h3>
  31. <h4>1. 异步加载出现异常后,弹出错误信息</h4>
  32. <pre xmlns=""><code>function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
  33. alert(XMLHttpRequest);
  34. };
  35. var setting = {
  36. callback: {
  37. onAsyncError: zTreeOnAsyncError
  38. }
  39. };
  40. ......</code></pre>
  41. </div>
  42. </div>