Blank Results

Oct 14, 2014 at 6:33 PM
Edited Oct 14, 2014 at 6:34 PM
Hello All, today is my first day using SPServices, but I've already reached a bump. Using the following script I get the "JQuery" alert but the alert($().SPServices.SPGetCurrentSite()); only returns "/".
<script type='text/javascript' language='javascript' src='/SiteAssets/javascript/jquery-1.8.3.min.js'></script>
<script type='text/javascript' language='javascript' src='/SiteAssets/javascript/jquery.SPServices-2014.01.js'></script>
<script type='text/javascript' language='javascript'>
  $(document).ready(function() {
    alert('JQuery');
    alert($().SPServices.SPGetCurrentSite());
  });
</script>
I've even tried to use the SPGetCurrentUser and it is just blank. Any help is appreciated.
I am using SharePoint 2013 on Premiss
Coordinator
Oct 14, 2014 at 7:26 PM
Edited Oct 14, 2014 at 8:37 PM
If you're in the root site, the "/" is actually correct. It's a relative link to the root site of the Site Collection.
http://servername/
M.
Oct 14, 2014 at 8:29 PM
I added the script to a sub site and it works perfect, but what about the SPGetCurrentUser it does not work on the root site either.
<script type='text/javascript' language='javascript' src='/SiteAssets/javascript/jquery-1.8.3.min.js'></script>
<script type='text/javascript' language='javascript' src='/SiteAssets/javascript/jquery.SPServices-2014.01.js'></script>
<script type='text/javascript' language='javascript'>
  $(document).ready(function() {
    var FName = $().SPServices.SPGetCurrentUser({fieldName: "FirstName", debug: false});
    var LName = $().SPServices.SPGetCurrentUser({fieldName: "LastName", debug: false});
    alert(FName + "::" + LName);
  });
</script>
Oct 15, 2014 at 12:07 AM
Alvin,
First thing I noticed is that you are using jQuery 1.8.3. I recommend you update that to 1.10.x or higher per Marc's release notes and see if that helps.
Coordinator
Oct 15, 2014 at 2:45 PM
The version of jQuery isn't likely to be the problem.

When you call $().SPServices.SPGetCurrentUser in the root site, are you getting any script errors? It ought to work.

Also, note that you can call $().SPServices.SPGetCurrentUser with fieldnames (note the "S") instead to get multiple values:
  var currentUser = $().SPServices.SPGetCurrentUser({
      fieldNames: ["FirstName", "LastName"],
  });
    alert(FName + "::" +  currentUser.FirstName);
M.