I am trying to load a CSS and a Javascript file from cross origin. I have also set the header Access-Control-Allow-Origin: * in the response but the browser doesn’t load the files, I load the CSS using the code given below:
var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", filename);
document.getElementsByTagName("head")[0].appendChild(fileref);
i want to load css and js using http connection which will be loaded in https :// [site]
Make sure that the
filenamevariable has the correct path withhttp://as part of it. Example:http://localhost:8080/css/style.cssorhttp://localhost:8080/project_folder/css/style.css