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

SPServices not loading,but alerts are showing

May 16, 2013 at 8:20 AM
here comes my scripts reference in the master page
<asp:ScriptReference Path="../../SiteAssets/js/jquery-1.8.3.js"></asp:ScriptReference>
<asp:ScriptReference Path="../../SiteAssets/js/jquery.SPService 0.7.2.js"></asp:ScriptReference>

and code here

//alert("jQuery loaded? " + (jQuery == undefined ? "NO!!!" : "YES."));
//alert("SPServices loaded? " + (jQuery.SPServices == undefined ? "NO!!!" : "YES."));

  operation: "GetGroupCollectionFromUser",
  userLoginName: $().SPServices.SPGetCurrentUser(),
  async: false,
  completefunc: function(xData, Status) {
   if ($(xData.responseXML).find("Group[Name='Site Admin']").length == 1) {
    alert('Yes,Its Admin')

I tried the above commented lines,my jquery is getting loaded ,but SPService is giving a no alert(not loading :( ) .. I tried an alert insdie SPService and i successfully got the alert,i dont understand wats the prob is !! >> pls help
May 16, 2013 at 12:14 PM

If the alert "Yes,Its Admin" is firing, then SPServices is working. Is that what you mean by "I tried an alert insdie SPService and i successfully got the alert"?

May 16, 2013 at 12:15 PM
You only need to post your question in one thread. I see all of the posts!

May 16, 2013 at 1:10 PM
oops..sorry for posting the same question in 2 threads...Thanks for the reply..
Inside SPServices.js i pasted an alert,that is working .But when i try in my page "alert("SPServices loaded? " + (jQuery.SPServices == undefined ? "NO!!!" : "YES.")); " this alert its giving me "SPServices loaded? No!!!" and "$().SPServices.SPGetCurrentUser()" is also throwing a null value
May 16, 2013 at 1:23 PM
Well, your alert is always going to say "NO!!!" the way you have it. This works:
alert("SPServices loaded? " + ($().SPServices == undefined ? "NO!!!" : "YES."));
What version of SharePoint are you using and what type of page are you calling the code from?

Your code runs fine for me in a console.

May 16, 2013 at 1:35 PM
Edited May 16, 2013 at 1:39 PM
Yes U r right ... I got the alert "SPServices loaded? YES." But not the second alert..
I am using sharepoint 2010,my code is in a js file and am calling it from a master page .Actually i want to check the logged user is in a particular group or not ..

and also tried
var userName = $().SPServices.SPGetCurrentUser({
    fieldName: "Title",
    debug: true
but alert (userName) is null
May 16, 2013 at 1:38 PM
Well, check that the user is in fact in that group and that the group is in the returned results. Given that SPServices is loaded and working, it'll be some debugging on your side at this point.

May 16, 2013 at 1:46 PM
the same code is working with some other subsites ,but only for one particular subsite its not working . And all the subsites are pointed to the same js files in the parent site. May be some other issue...Anyways thanx for the reply ..