This project has moved and is read-only. For the latest updates, please go here.

$().SPServices.SPGetCurrentSite Documentation

Jul 10, 2014 at 4:04 PM
Marc, In the "SPGetCurrentSite" function's documentation, it states the function will return the complete site URL.

I noticed in the lated release (2014.01), the "SPGetCurrentSite" function returns the string from "currentContext.thisSite" (if available). That result is a relative URL, stripping the protocol and domain from the front end. i.e., returns "/sites/path/subpath" instead of "https://mydomain/sites/path/subpath" (at least it does so in IE and SP 2007). It's not a huge deal unless the user's code is doing a full text comparison of that string and is expecting the full URL (as was my case in a particular instance--which is how I discovered this).

I noticed the code will defer to a web service call (WebUrlFromPageUrl) to get the URL if "currentContext.thisSite" isn't available. The web service returns the complete site URL. So, in this function, the two methods will return the string to the user differently depending on the method the function uses. That may cause some confusion in the long run.


Aug 1, 2014 at 2:36 PM
Edited Aug 1, 2014 at 2:38 PM
First: I'm not sure if this is the right location for additional info on this issue ...

I experienced the same behavior. thisSite has a value of "/". So it's not empty and will be used as base url for ajax calls. My calls ended up like: https://_layouts/userdisp.aspx?Force=True&1234567890. Obviously, my browser ended up nowhere.

I made an adjustment to the SPServicesContext function:

FROM: this.thisSite = _spPageContextInfo.webServerRelativeUrl;
TO: this.thisSite = _spPageContextInfo.webAbsoluteUrl;

It seems that my ajax calls are being executed now.

Aug 2, 2014 at 6:07 AM
It sounds like I have a bug. I'll put it in the list to check and/or fix for the next release.

Aug 2, 2014 at 6:11 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 16, 2014 at 2:45 PM
I've just uploaded a new alpha (2014.02ALPHA5) with a fix for this issue and a couple other things. If you could try it out and let me know if it works for you, that would be very helpful.

Oct 17, 2014 at 1:39 PM
Edited Oct 17, 2014 at 1:46 PM
When I open the page at, I get a message stating "The specified release was not found." However, I looked at the issue thread and see that you posted the updated version of the private function “SPServicesContext().” I copied that into my copy of 2014.01 (rem’d out the original function). I tested it on a 2007 site and a 2010 site using list views/forms and then a custom page. Everything appears to work as advertised. Looks great, thanks!

Oct 17, 2014 at 2:03 PM

Somehow the new release got marked as hidden. Sorry about that. You should be able to reach it now if you want to.

Glad to hear that it worked!