I want to fetch termstore, Termsets and related terms. However, I'm not able to fetch the termstore.
I'm receiving the error message:
404 not found
This is the code I'm using:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(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", function () {
context = SP.ClientContext.get_current();
//Call your code here.
getTermStores();
});
});
});
});
function getTermStores() {
session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
termStores = session.get_termStores();
context.load(session);
context.load(termStores);
context.executeQueryAsync(function(){
termStoresEnum = termStores.getEnumerator();
var termStores = "Term Stores: /n";
while (termStoresEnum.moveNext()) {
var currentTermStore = termStoresEnum.get_current();
var termStoreID = currentTermStore.get_id();
var termStoreName = currentTermStore.get_name();
termStores += "Name: " + termStoreName + " ID:" + termStoreID;
}
}, function(){
//failure loading termstores.
});
}
</script>