我的模板js文件是通过codeigniter 3.1中的loader控制器加载的 它在我的本地xampp服务器上工作正常。但不适用于Chrome浏览器的远程服务器。只能在远程服务器的mozila firefox中工作。 Chrome拒绝执行来自' https://xxxxxxxx.com/loadlanguage/all.js'因为它的MIME类型(' text / html')不可执行,并且启用了严格的MIME类型检查。
public function jsFile($file = null)
{
$contents = file_get_contents('.' . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR . MY_LANGUAGE_FULL_NAME . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . $file);
if (!$contents) {
header('HTTP/1.1 404 Not Found');
return;
}
echo $contents;
}
我的js文件是
var lang = {
added_to_cart:"Added to cart",
error_to_cart:"Problem with shopping cart! Try again!",
no_products:"No products",
confirm_clear_cart:"Are you sure want to delete items in shopping cart?",
cleared_cart:"Your cart is empty",
are_you_sure:"Are you sure?",
yes:"Yes",
no:"No",
clear_all:"Clear",
checkout:"Payment",
remove_from_cart:"Deleted from shopping cart",
enter_valid_email:"Please enter a valid email address",
};
js文件可以通过链接状态200访问,但不能在chrome中工作,它在mozila中工作正常。 请帮助解决它。