locked
Odd JQuery Error RRS feed

  • Question

  • Currentlyk,we have a dev, stage and prod environment.  I have a reference to the JQuery library at the bottom of my Master page.  This works fine in the environments mentioned above:

            <!--//// GHC Custom JS Scripts  -->
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/jquery-1.12.0.min.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/jquery-ui.min.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/jquery.browser.min.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/jquery.cookie.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/fancybox/jquery.fancybox.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/fancybox/jquery.fancybox-buttons.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/fancybox/jquery.fancybox-thumbs.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/jquery.easing-1.3.pack.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/jquery.mousewheel-3.0.6.pack.js"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/libraries/bootstrap.min.js?rev=6-2-2016"></script>
            <script type="text/javascript" src="/_layouts/15/GHC.Refresh/scripts/site.js?rev=6-2-2016"></script>
    
            <GHC:GoogleAnalytics ID="GoogleAnalytics" runat="server"/>
    	</body>

    I've just created a new dev environment.  However, for some reason the site throws an object not found error when I try to use the document.ready/jquery functions.  If I move the jquery reference to the top of the page in the header, the error goes away, but I get syntax errors when trying to use JSON.parse().    I shouldn't have to move the reference around and I'm completely stumped as to what would cause this.  Does anyone know what's happening/how to fix?

    Monday, June 20, 2016 1:23 PM

Answers

  • I gave up and moved the jquery reference from the body to the head.  I'm not sure why this should matter, but it fixed the issue.  The JSON.Parse() was a separate issue that had to do with resource throttling, which has been fixed as well.
    Monday, June 20, 2016 3:40 PM

All replies

  • Hi,

    You need to locate the user control related assembly file and WSP in your old environment and deploy it on new server.


    Murugesa Pandian | MCPD | MCTS | SharePoint 2010 |

    Monday, June 20, 2016 1:54 PM
  • Thanks for getting back to me.  I'm not sure if I'm following you correctly, but I believe I did that.  I grabbed the solution from the other environment and deployed it.  I then tried viewing the home page and noticed the '$' is not defined error.  Is that what you meant?

    Thanks again

    Monday, June 20, 2016 2:03 PM
  • Are you able to locate the folder GHC.Refresh and the scripts in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\ post solution deployment? if you have multiple front end servers check the above folder structure and make sure its available.

    Also in the browser, try like 

    http(s)://your_new_Dev_site_url/_layouts/15/GHC.Refresh/scripts/libraries/jquery-1.12.0.min.js and see whether you are able to access the jquery files.

     

    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    Monday, June 20, 2016 2:11 PM
  • Yes, I put an alert in the jquery file to make sure its finding it.  It alerted me when I refreshed the page, so the reference is correct.  Its just a dev server as well so there is only one front end.  Weird huh?
    Monday, June 20, 2016 2:13 PM
  • Seems that you missed the custom deployment of WSP: GHC.Refresh.

    Check to hit the page: /_layouts/15/GHC.Refresh/scripts/libraries/jquery-1.12.0.min.js

    If jQuery is not giving 404 error.

    Also, if $() doesn't work try jQuery();


    Regards,

    Farshid Mahdavipour, MCSE, PMP

    Blog: www.sharepointjunkies.com
    ---------------------------------------------------------------------
    Please don't forget to mark it as answered, if your problem resolved or helpful.

    Monday, June 20, 2016 2:15 PM
  • Now, You misplaced the jQuery file and related control's dependency javascript files.

    Murugesa Pandian | MCPD | MCTS | SharePoint 2010 |

    Monday, June 20, 2016 2:16 PM
  • Hi, thanks for getting back.

    It does not give a 404 error/its finding the jquery library.  I've checked the 15 hive and all the dependences are there.  I verified that there is no other jquery library getting loaded as well.

    I've tryied jQuery() and still get the error.  If I move the jquery reference from the body into the header I no longer get the '$' is undefined error, but other functions throw syntax errors ie JSON.Parse() doesn't work.

    I'm not sure what's going on, but it seems like the jquery library is getting loaded after my custom js.  I will let you know if I figure anything out on this.  Its just weird as this should be straight forward and work as its just a simple javascript reference.



    • Edited by Jamezn2013 Monday, June 20, 2016 2:27 PM
    Monday, June 20, 2016 2:25 PM
  • I gave up and moved the jquery reference from the body to the head.  I'm not sure why this should matter, but it fixed the issue.  The JSON.Parse() was a separate issue that had to do with resource throttling, which has been fixed as well.
    Monday, June 20, 2016 3:40 PM