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

  • 1
    If you watch the browser traffic from the F12 Developer Tools, is it requesting the library? Commented Jul 31, 2012 at 16:30
  • Where is jQuery loaded? Any not published version of that file? Commented Jul 31, 2012 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. Commented Jul 31, 2012 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
    Commented Aug 1, 2012 at 8:09
  • Ignore the 404, that was just something I had missed when try other options.
    – Craig
    Commented Aug 1, 2012 at 8:33

2 Answers 2



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

  • Glad to see you got it resolved. Please mark this as the answer. Commented Aug 1, 2012 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.

  • 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
    Commented Aug 1, 2012 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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