SharePoint Asked by Kandace on December 31, 2021
Newbie so please don’t beat me up.
I’m trying to run a simple javascript function using the jquery library. I’ve tested it on jsbin and it runs. However when I go to my SharePoint 2013 page, insert a Script editor web part and insert the code. It keeps hanging up at $ not defined. So that tells me it’s not loading the jquery library even though I have referenced it:
“>. FYI: I also tried using the absolute url as well and no difference.
I’ve been reading in at least two places that I can add a reference to the jquery library in the script editor web part. I know I should be adding it to a Master Page ideally but for now can someone please verify whether or not you can reference your jquery library in a script editor webpart. Thanks in advance.
Troubleshooting
Possible solutions
Add jquery file in Site assets library in your site and refer it in your code(You can can also use CDN. But keeping jquery file in your site is best way in my point of view).
If you are loading jQuery file multiple times on your page then there maybe the error because of jquery conflict. To avoid that use code given in my answer: jQuery and jQuery multi file upload scripts are not loading
Answered by Ganesh Sanap on December 31, 2021
Add the following JavaScript into script editor web part to check if it works.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
alert("Test");
});
</script>
If you can't access the external web in the server, we can download the jQuery library and upload the js file into Site Assets library, then using the code below to test.
<script src="http://sp2013/SiteAssets/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
alert("Test");
});
</script>
Answered by LZ_MSFT on December 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP