SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a very strange problem where there is some custom jquery interface buttons to show and hide certain fields in sharepoint. The script builds fine(script that has worked on previous sites) but does not execute for most users (appears users that are site collection administrators).

Even the simplest part of code: $('.ms-formlabel').closest('tr').hide();

Throws: "Object expected"

Running: typeof jQuery == 'undefined'; Returns: true

Looking into this shows:

If anyone has any ideas what could be causing this, it would be much appreciated as this is driving me crazy.

This is a sharepoint 2010 enterprise deployment if this is relevant

share|improve this question
If you watch the browser traffic from the F12 Developer Tools, is it requesting the library? – RJ Cuthbertson Jul 31 '12 at 16:30
Where is jQuery loaded? Any not published version of that file? – Per Jakobsen Jul 31 '12 at 16:47
how are you adding the jQuery reference? Master page? custom action? script tag in a content editor? As rj stated above, F12 this from an affected user's computer to see what's going on. – Derek Gusoff Jul 31 '12 at 17:31
The Jquery is added in the webpart - just before the actual javascript code and pulls in fine for some users. Something worth noting though is that in the F12 window if I try to view the jquery-ui.min.js file with the users having the issue i get 404 but normal behaviour for the working users – Craig Aug 1 '12 at 8:09
Ignore the 404, that was just something I had missed when try other options. – Craig Aug 1 '12 at 8:33
up vote 1 down vote accepted


This was caused by different users getting a different masterpage, which was missing certain references that the jquery needed.

share|improve this answer
Glad to see you got it resolved. Please mark this as the answer. – Derek Gusoff Aug 1 '12 at 13:50

1) Check if jQuery is loaded more than once. You should check this with Developer Tools.

2) Try it like this:


3) It could be a permission issue. Just to check this, put the script in the _catalogs/masterpage library and reference it from there. The Master Page gallery is accessible to all users and if it works from there, we can be sure that it's a permission issue.

share|improve this answer
Jquery is loaded only once, Using that had no effect - still getting object expected if trying to run a line of jQuery('.ms-formlabel').closest('tr').hide();, I uploaded to the gallery you specified but no success – Craig Aug 1 '12 at 8:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.