一、查询指定的Termset及子项
<script type="text/javascript" src="/Style%20Library/aaaa/Scripts/jquery-1.11.1.min.js" language="javascript"></script> <script type="text/javascript">RegisterSod("sp.taxonomy.js", "\u002f_layouts\u002f15\u002fsp.taxonomy.js?rev=l0dFB37050OQxbmrgu6z7Q\u00253D\u00253D");</script> <script type="text/javascript"> $(document).ready(function () { var scriptbase = _spPageContextInfo.webServerRelativeUrl + "_layouts/15/"; $.getScript(scriptbase + "SP.Runtime.js", function () { $.getScript(scriptbase + "SP.js", function () { $.getScript(scriptbase + "SP.Taxonomy.js", execOperation); }); } ); }); function execOperation() { //Current Context var context = SP.ClientContext.get_current(); //Current Taxonomy Session var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context); //Term Stores var termStores = taxSession.get_termStores(); //Name of the Term Store from which to get the Terms. var termStore = termStores.getByName("IdeaTracker_MMS"); //GUID of Term Set from which to get the Terms. var termSet = termStore.getTermSet("bcf031d3-7eb2-433a-b5ff-b92398758431"); var terms = termSet.getAllTerms(); context.load(terms); context.executeQueryAsync(function () { var termEnumerator = terms.getEnumerator(); var termList = "Terms: \n"; while (termEnumerator.moveNext()) { var currentTerm = termEnumerator.get_current(); termList += currentTerm.get_name() + "\n"; } alert(termList); }, function (sender, args) { console.log(args.get_message()); }); } </script>