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

SPServices v2013.02 Fails with error currentContext.thisSite is undefined

Dec 30, 2013 at 2:58 PM

So I know I did some testing on this over the weekend, but in a O365 environment... This problem was not present there... At the office, however, running SP2010, I get an error from SPServices the first time I try to use the $().SPServices.SPGetCurrentSite()

The problem is the SPServicesContext() Constructor - It is using _spPageContextInfo.webAbsoluteUrl which in this production environment is not defined (maybe MS added that in a patch?). Here is what's defined for _spPageContextInfo:
I was using 2013.02 ALPHA3 before and did not get this error, so since I have my code under source control, I did a DIFF against the prior version... Looks like you changed SPServicesContext between ALPHA3 and BETA3 - it was using _spPageContextInfo.webServerRelativeUrl before.


(I'm forking my version to fix it (setting it back to webServerRelativeURL)

Jan 2, 2014 at 6:13 PM
Edited Jan 2, 2014 at 6:13 PM

I could have sworn I tested this fully on SP2010 and it worked. I've just pulled up my 2010 VM and here are the values I see:

Is this consistent with what you've got?

Jan 2, 2014 at 9:39 PM
Yes, that matches the SP2010 environment I have access to.

Jan 3, 2014 at 2:13 PM
I'm stuck in upgrading from Win7 to Win8.1 hell at the moment, but I plan to get a fix out ASAP. I'll need to change the ajaxUrl construction, too.

I can't believe I missed this.

Jan 3, 2014 at 3:35 PM
Yeah, I saw your tweet that you were synchronizing the versions of windows at home :) - fun!

Hmmm. I made the change inreferenced above and have not hit any other issues. I'll take a quick look at the ajaxUrl.

Let me know if there is anything I can help with.


Paul T

Jan 3, 2014 at 5:00 PM

It's a matter of checking to see if the value for currentContext.thisSite ends in a slash or not correctly.

In the case of 2007 we can use the L_Menu_BaseUrl JavaScript variable where I've been making a call to WebUrlFromPageUrlResult. That value doesn't have a trailing slash.

Too many versions to test!

Jan 3, 2014 at 5:01 PM
Jan 3, 2014 at 6:47 PM
Ahh. Got it. Thanks.


Paul T