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

SPServices doesn't work when master page gets added.

Jul 6, 2012 at 4:12 PM
Edited Jul 6, 2012 at 4:14 PM

I have spent literally more than 10 hours trying to make this work! 

Here is what I am trying to do. I am basically getting the current logged in user and present customized view. I started the page without master page, added view, used SPServices and some jQuery and everything seems great and working. 

However, the moment, I added master page, SPServices fails on IE! ONLY IE! It seems fine on Chrome/Firefox, but for some reason not in IE. 

I am playing with following basic lines.


$(function() {
		currentUser = $().SPServices.SPGetCurrentUser({
			fieldName: "Title",
			debug: false

I am getting current user in Chrome but not in IE. In IE, it just give me blank. Any ideas why it's happening? Any ideas/suggestions will be greatly appreciated.

Jul 6, 2012 at 4:23 PM
Do you have your code inside the $(document).ready(); method?

Paul T

Jul 6, 2012 at 4:30 PM

Yes I do.



$(document).ready(function() {
		currentUser = $().SPServices.SPGetCurrentUser({
			fieldName: "Title",
			debug: false

Here is what I don't understand, jQuery has loaded succesfully, SPServices has loaded successfully as it does traverse through those files when I debug, but have no clue why it would be empty.

Jul 6, 2012 at 6:14 PM

Is currentUser variable initialized?

var currentUser = $().SPServices.SPGetCurrentUser({

Jul 6, 2012 at 6:28 PM

It is declared as global variable. 

Jul 6, 2012 at 6:50 PM

Make sure that the script files are loading in the right place in the page. When you attached the master page, where did the <script> tags end up?

IMO, building in a "real" page initially would make more sense, anyway. I usually just take a copy of an existing page to start with.


Jul 6, 2012 at 10:17 PM

Hi Mark,

Sorry for the late reply as I was trying to make it work using other way but still no success. 

The structure seems fine. All the <script> tags showed up in head section as expected. The only thing that I notice is, jQuery file and SPServices files are loading right before $(function) and after as well. The former one is from page itself and latter one is from Master page, but that shouldn't matter I would think. 

Also, I Have found that, it did work on IE9 compat mode, so the only glitch is IE9! Haven't tested in IE8 yet. I don't know if I am the only one with this problem...kinda frustrating as it seems like minor issue but taking quite a bit of time. 

For the record, I also tried: and whenever callback is involved, I get error like 'Cannot read property 'webServerRelativeUrl' of undefined' referring SP.js

Please help if you have some bandwidth. 

Jul 7, 2012 at 1:09 AM

I did manage to do it without SPServices i.e. native calls.. however still having little bit of glitch. 

Basically, whenever I try to do stuffs in document.ready() function, stuffs don't seem to work but outside the document.ready seems to work. It's kind of bit mystery for now, but will post once I figured out why it's doing what it's doing. 

Jul 7, 2012 at 4:54 AM

My suggestion would be to start with a fresh page and add each piece in one at a time, checking if things are working as you go. Something's out of whack. The double loads *will* cause problems, most likely, or at least are an indication that something isn't right.


Jul 9, 2012 at 1:55 AM

Thanks for the reply Mark. 

I feel like it's truly IE9 bug! Does't load scripts in right order...actually even that doesn't make sense as I was able to debug through all files..

For the moment I am just skipping it as it's working use JCOM, but the only pain to is all the calls are asynchronous.

Side question Mark, how does SPServices manages to call the functions synchronously? Thanks for all the replies Mark! You are truly a hero!  

Jul 9, 2012 at 3:35 AM

Not a hero; just the guy who does the work. ;=)

SPServices simply leverages the jQuery .ajax() function, which provides the sync/async option.


Jul 9, 2012 at 6:32 PM

"SPServices simply leverages the jQuery .ajax() function, which provides the sync/async option" sounds like a treasure to me! Thanks for sharing your expertise!