$().SPServices() NOT working inside a function, but WORKS outside of one?!

Oct 9, 2013 at 3:14 PM
I've got some code i'm using for testing the access of list data which i'm outputting to the screen. Taking this code and putting it inside a script tag, inside a content web part and running it - works.

If I take the same exact code, and wrap it inside two nested ajax functions which I'm using to check a users group membership, and then call a function with this same code inside, IE breaks execution of the javascript with the error :

SCRIPT438: Object doesn't support property or method 'SPServices'

Both code blocks are on the page while im testing, and the working version always executes and outputs to the page, whereas the async version fails every single time.

Any ideas!?
Oct 9, 2013 at 3:34 PM
If possible could you supply some code so that it would be easier to assist??
Coordinator
Oct 9, 2013 at 3:37 PM
The "Object doesn't support property or method 'SPServices'" error almost always means that your reference to the SPServices .js files isn't correct. However, given that you say you had simple access working already, that may not be the issue. My guess is that you're missing a semi-colon, bracket, or parenthesis.

M.
Oct 9, 2013 at 4:23 PM
Well, I found a 'fix' for this, although it doesn't feel right, as I'm just repeating a script reference.

Adding the following line to the function at the top :

$.getScript("http://development.local/_catalogs/masterpage/xxxxx/jquery.SPServices-0.7.2.js");

... makes it all work.

Maybe I need coffee, but I'm unsure as to how the code block is losing sight of the script references already in place. As mentioned before, the same block of code outside my logic works correctly.

I've also checked all the code before the SPServices call for any missing syntax and it was all fine.
Coordinator
Oct 9, 2013 at 4:32 PM
Can you show what you're doing? It's hard to know what to suggest without seeing anything.

M.
Oct 10, 2013 at 12:40 AM
Seeing the full code - what works and what does not *in the same page* - would definitely help.

Given your reference bow to spaervices script, how at you including it on the page? Via a CEWP? Or in the master page?

Paul.


--
Paul T.

-- Sent from Mobile