0

I am a SP Admin and new to coding. From the below script, i am not sure what should i keep as my site name. I am placing that script in content editor web part in the site https://sharepoint.com/sites/sitecollection. According to this site, what should be my url from the below script be?

i tried to use cdn links SP Services, but the script is not loading, it says the script is not safe.

<script src="https://site name/jquery.min.js"></script>  
<script src="https://sitename/jquery.SPServices.min.js"></script>  
<script type="text/javascript">  
$(document).ready(function ()  
{  
    $().SPServices.SPCascadeDropdowns(  
    {  
        relationshipList: "Employee",  
        relationshipListParentColumn: "Company",  
        relationshipListChildColumn: "Title",  
        parentColumn: "Company",  
        childColumn: "Employee",  
        debug: true  
    });  
});  
</script> 
1

You could use the following link:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.6.2/jquery.SPServices-0.6.2.min.js" type="text/javascript"></script>

Code:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.6.2/jquery.SPServices-0.6.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
    $(document).ready(function ()  
    {  
        $().SPServices.SPCascadeDropdowns(  
        {  
            relationshipList: "Employee",  
            relationshipListParentColumn: "Company",  
            relationshipListChildColumn: "Title",  
            parentColumn: "Company",  
            childColumn: "Employee",  
            debug: true  
         }); 
    });  
</script> 
| improve this answer | |
1

I don't see 'folder name' part in URL provided by you.

Follow next steps to upload JS files on your site in order to be able to use these scripts:

  • Visit your site - https://sharepoint.com/sites/sitecollection
  • Click on Site contents > Site Assets
  • Upload JS files to Site Assets folder(or any other document library)
  • Open web page(or list form) where you want to use scripts
  • Add new Script Editor Web Part(or Content Editor Web Part)
  • Add your code

    <script type="text/javascript" src="/sites/sitecollection/SiteAssets/jquery.min.js"></script>  
    <script type="text/javascript" src="/sites/sitecollection/SiteAssets//jquery.SPServices.min.js"></script>  
    <script type="text/javascript">  
        $(document).ready(function ()  
        {  
            $().SPServices.SPCascadeDropdowns(  
            {  
                relationshipList: "Employee",  
                relationshipListParentColumn: "Company",  
                relationshipListChildColumn: "Title",  
                parentColumn: "Company",  
                childColumn: "Employee",  
                debug: true  
             }); 
        });  
    </script> 
    
| improve this answer | |
1

If you are prefixing src url with https:// then it needs to be the full absolute url (https://sharepoint.com/sites/sitecollection), if you want to use a server-relative url in case your server name changes, then do not use the https:// protocol prefix.

For example: <script src="/sites/sitecollection/SiteAssets/jquery.min.js"></script>

| improve this answer | |
  • when i tried to access the url : sharepoint.com/sites/sitecollection/jquery.min.js it says 404 not found, – Achiever SP Jan 8 at 19:30
  • where did you upload your jquery source? Did you put in a scripts folder or site assets library? Make sure you have the full path to wherever you stored your javascript files. – willman Jan 8 at 19:32
  • If your copy of the jquery libraries are in the root of your SiteAssets library, I updated the example in my answer to reflect that. If you have the library files in a subfolder or in a different library, make sure to include that in your path. – willman Jan 9 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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