Rich-text Reply

RESOLVED: No matter what I try, loading external JS file does not work. Help?

mkstvnsn 10-20-16

RESOLVED: No matter what I try, loading external JS file does not work. Help?

[ Edited ]

Please ignore. The file was HTTP and should have been HTTPS. Mixed content was being blocked.

 

Hi guys. I've tried everything I can think of to get an external script to load to no avail. 

I've tried https://developers.optimizely.com/classic/javascript/code-samples/index.html#helpers-external-js to a T and the script is not loaded on the page. 

 

I put the below in my experiment JS and nothing happens on the page. I've tried simple methods like appending and again, nothing happens.

 

var loadScript = function(location, callback){
var fileRef = document.createElement('script');
fileRef.setAttribute('type','text/javascript');

if (callback) {
if (fileRef.readyState) { // IE
fileRef.onreadystatechange = function() {
if (fileRef.readyState == 'loaded' || fileRef.readyState == 'complete') {
fileRef.onreadystatechange = null;
callback();
}
};
} else { // Non-IE
fileRef.onload = function(){
callback();
};
}
}

fileRef.setAttribute('src', location);
document.head.appendChild(fileRef);
};

loadScript('http://www.site.info/_files/cc_validate.js', function() {
});

Level 2

rockymcg 10-21-16
 

Re: RESOLVED: No matter what I try, loading external JS file does not work. Help?

Hello, 

 

Glad to hear the issue was resolved. Thanks for posting to Optiverse!

 

Best,

Rocky

Optimizely