Guest User

Untitled

a guest
Apr 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function getRootWeb() {
  2. //Get and load a reference to the root web of the current site collection.
  3. var ctx = new SP.ClientContext("http://Server/sites/sitecollection/");
  4. var site = ctx.get_site();
  5. var rootWeb = site.get_rootWeb();
  6.  
  7. ctx.load(rootWeb);
  8. //Ask SharePoint to pull data for us
  9. ctx.executeQueryAsync(onQuerySucceed,onQueryFailed);
  10. };
  11.  
  12. //Function executed on success
  13. function onQuerySucceed() {
  14. alert(this.rootWeb.get_title());
  15. };
  16.  
  17. //Function executed on failure
  18. function onQueryFailed(sender, args) {
  19. alert('Unable to retrieve data from the SharePoint. Request failed. ' + args.get_message() + 'n' + args.get_stackTrace());
  20. };
Add Comment
Please, Sign In to add comment