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.

No comments:

Post a Comment