SP services is not null or not an object

Mar 20, 2013 at 6:03 PM
I keep getting this error and unable to resolve this. And I have already spent days on Google and trying to fix but all in vain.
I tried the absolute and relative URL references. and references seems to be fine.
Tried using content editor webpart
Saved the script files in the library on the same site and have all the access permissions.
I tried the same thing on other machine and everything is working fine. But I guess something is wrong with Sharepoint environement or something to do with my machine setting or network policies I don't know.


Does anyone out there know how to fix this or possible solution could be?

Help is much appreciated.
Coordinator
Mar 20, 2013 at 6:39 PM
"SP services is not null or not an object" means that your reference to the script file isn't correct. Even though you've checked them, check them again.

Look at this post for some hints:
http://sympmarc.com/2011/07/08/adding-jqueryspservices-to-a-sharepoint-page-step-one-always/

There's also information at the bottom of the first documentation page.

M.
Mar 21, 2013 at 3:35 PM
Thanks for the reply.


I tried to follow the link.


I got the jquery alert message but did not get the any alert from SPservice Reference. I also did not get any messages like 'undefined' or any value which makes no sense.


When Page is loaded, I see the same error on bottom left of IE. 'SPServices' is null or not an object.


Can you please suggest me something else which I can get this thing done.
I appreciate your time.
Coordinator
Mar 21, 2013 at 3:47 PM
Edited Mar 21, 2013 at 3:48 PM
Can you post the code where you are referencing the files?

M.
Mar 21, 2013 at 3:56 PM
<script language="javascript" type="text/javascript" src="../../Scripts/jquery-1.6.2.min.js"></script>
<script language="javascript" type="text/javascript" src="../../Scripts/jquery.SPServices-0.7.2.js"></script>
<script language="javascript" type="text/javascript"> $(document).ready(function() { alert("jQuery"); alert($().SPServices.SPGetCurrentSite()); }); /* $(document).ready(function() { $().SPServices.SPCascadeDropdowns({ relationshipList: "ProjectTypeProjectName", relationshipListParentColumn: "ProjectType", relationshipListChildColumn: "ProjectTitle", parentColumn: "ProjectType", childColumn: "ProjectName", debug: true }); }); */ </script>
Coordinator
Mar 21, 2013 at 4:11 PM
OK, so this says that you have both the jQuery library and SPServices stored up two layers from the current location. I would always suggest using a relative path from the root site, so for example:

/siteA/Scripts/jquery-1.6.2.min.js

If the jQuery alert is happening and the SPServices one isn't, then that reference must not be correct. Are you sure you are storing both files in the same place?

BTW, I would suggest using jQuery 1.8.3.

M.
Mar 21, 2013 at 4:16 PM
I tried the relative path too and also both files are under same library. It keeps giving me the same error.


These two versions are compatible and working fine on my other machine.

I am wondering if I had to do anything with the machine I am getting this error.

Is there a possibility that network policies or proxy setting or something would be a cause to this error.
Coordinator
Mar 21, 2013 at 4:27 PM
Probably not. You could try looking at the network traffic with Firebug or Fiddler to see if you are getting an error loading the file.

M.
Mar 21, 2013 at 4:49 PM
Tried that too. I used firebug.


Error message in console is "Uncaught typeError: Cannot call method 'SPGetCurrentSite' of undefined"
Coordinator
Mar 21, 2013 at 5:18 PM
I meant to look at the Net traffic to see if the SPServices file is actually fetched successfully.

M.
Mar 28, 2013 at 5:33 PM
After more than 10 days of struggle I was able to find the solution.. well I don't know but the problem is solved with the help of my friend.


We tried many things but finally did nothing much but changed scripts to jquery-1.8.2.js and jquery.SPServices-0.7.2.min.js . It is working fine now.


Here, take a look at this working script.


<script src="/Scripts/jquery-1.8.2.js" type="text/javascript"></script><script src="/Scripts/jquery.SPServices-0.7.2.min.js" type="text/javascript"></script><script type="text/javascript">


$().SPServices.SPCascadeDropdowns({
    relationshipList:"ProjectTypeProjectName",
    relationshipListParentColumn:"ProjectType",
    relationshipListChildColumn:"Title",
    parentColumn:"ProjectType",
    childColumn:"ProjectName"
});


</script>



Hope this helps someone.


Sympmarac, thanks for responding quickly. I appreciate your effort and time. :)
Coordinator
Mar 28, 2013 at 8:20 PM
It had to be that your file references weren't right. Note that your paths are different in what you ended up with.

Anyway, glad that you solved it.

M.