setting.async.url.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>String / Function(treeId, treeNode)</span><span class="path">setting.async.</span>url</h2>
  4. <h3>Overview<span class="h3_info">[ depends on <span
  5. class="highlight_green">jquery.ztree.core</span> js ]</span></h3>
  6. <div class="desc">
  7. <p></p>
  8. <div class="longdesc">
  9. <p>The URL to which the ajax request is sent. It is valid when <span class="highlight_red">[setting.async.enable = true]</span>
  10. </p>
  11. <p>Default: ""</p>
  12. </div>
  13. </div>
  14. <h3>String Format</h3>
  15. <div class="desc">
  16. <p>A url string(e.g. "http://www.domain.com/cgi-bin/my-script.cgi"). Note: please check that the url can be
  17. loaded with a browser</p>
  18. <p class="highlight_red">Url can also take parameters, please note that they need to be urlencoded.</p>
  19. </div>
  20. <h3>Function Parameter Descriptions</h3>
  21. <div class="desc">
  22. <h4><b>treeId</b><span>String</span></h4>
  23. <p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
  24. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  25. <p>Parent node's JSON data object</p>
  26. <p class="highlight_red">When asynchronously loading the root, the treeNode = null</p>
  27. <h4 class="topLine"><b>Return </b><span>String</span></h4>
  28. <p>Return value is same as 'String Format'</p>
  29. </div>
  30. <h3>Examples of setting & function</h3>
  31. <h4>1. set ajax url is "nodes.php"</h4>
  32. <pre xmlns=""><code>var setting = {
  33. async: {
  34. enable: true,
  35. url: "nodes.php",
  36. autoParam: ["id", "name"]
  37. }
  38. };
  39. ......</code></pre>
  40. <h4>2. set ajax url is "function"</h4>
  41. <pre xmlns=""><code>function getAsyncUrl(treeId, treeNode) {
  42. return treeNode.isParent ? "nodes1.php" : "nodes2.php";
  43. };
  44. var setting = {
  45. async: {
  46. enable: true,
  47. url: getAsyncUrl,
  48. autoParam: ["id", "name"]
  49. }
  50. };
  51. ......</code></pre>
  52. </div>
  53. </div>