Tuesday, December 2, 2014

JavaScript / jQuery not loading in a site with SSL

This is quite related to the previous post, but decided to split it as some people might just have the generic issue of JavaScript not kicking in on their SharePoint sites... when they use jQuery and SSL :)

The issue might be very simple, and usually the first thing to do when your script is not loading is to see how the Developer Tools look like in your browser. When you use SSL and refer to the jQuery library in a JavaScript, make sure you use the https:// prefix, otherwise your script won't load at all and you'll end up with the error below and maybe an error displayed in the browser saying "Only secure content is displayed", depending on which browser you use and its settings.


You can of course workaround this in the browser itself by doing the following (example for IE) but I strongly recommend doing it the right way in your script in the first instance so you don't have to mess with end-user settings at all. Use this workaround for testing purposes only.

Tools -> Internet Options -> Security, Custom level -> Scroll to: Display mixed content -> Enable -> OK -> Restart IE.

Usually the best practice is to store jQuery locally in the SharePoint farm (in a library for example) and then refer to it in your script. That way you ensure the protocol will be consistent between the site and the location of jQuery.

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru JavaScript Online Training India. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai

    ReplyDelete