gpt4 book ai didi

javascript - 拒绝加载脚本 'https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js'

转载 作者:行者123 更新时间:2023-11-28 02:31:51 24 4
gpt4 key购买 nike

net。我正在使用 jQuery 执行一些操作。当我将我的代码部署到本地时,它工作正常。但是当我将相同的代码部署到实时服务器时。控制台中出现错误:

Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".

请检查我的 html 代码以供引用-:

<html>
<head>
<title>Notifications</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link type="text/css" rel="stylesheet" href="./Content/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="./Content/style.css" />


<script type="text/javascript" src="./Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="./Scripts/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
</head>
<body>

<h2>Send</h2>

<div>
<textarea id="text_message" rows="12" cols="100" placeholder="Please Type Your Message"></textarea>


<div style="margin: 5px">

<input type="button" value="Submit" onclick="sendPush()" />
</div>
<div class="loadermodal" style="display: none">
<div class="center">
<img alt="" src="./Content/img/ajax-loader.gif" />
</div>
</div>
</div>

<script>
function sendMessage() {

var comment = $.trim($("#text_message").val());
if (comment != "") {
// Show alert dialog if value is not blank
// alert(comment);
$(".loadermodal").show();
$.post("/PushNotification/sendPushNotificationToAll", { 'message': comment }).done(function (data) {
var obj = jQuery.parseJSON(data);
if (obj.success != "0") {
alert("Message Sent Successfully");
$(".loadermodal").hide();
}
else
alert("Error in Sending Push");
});
}
else {

alert("Enter Some Text To Send A Message");

}
}



</script>

</body>

在这里,在这段代码中,我创建了一个简单的文本框来编写消息和一个将执行脚本的按钮。这个脚本在我的本地运行良好,但是当我将相同的代码部署到我的应用程序服务器时,这种类型控制台中出现错误。

请分享你对这个问题的看法

谢谢

最佳答案

解决此错误的最简单且更可靠的方法是将源代码从 url 复制到您的 /Scripts/目录并使用以下方式引用文件:

<script type="text/javascript" src="./Scripts/jquery.csv-0.71.min.js"></script>

看起来您已经在使用 jQuery 和 Bootstrap 文件执行此操作。此方法允许您将存储库中的所有依赖项保持在所需的版本。

除此之外,此错误是为了防止您的网络服务器从您不维护的位置加载潜在的恶意脚本。大多数网络服务器都有允许这样做的设置,但它们最初是禁用的(有充分的理由)。

话虽如此,我仍然建议下载源代码并将其包含在您的项目中。

关于javascript - 拒绝加载脚本 'https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50136589/

24 4 0
文章推荐: css - nth-child 在其他元素中选择 div 有什么选择?
文章推荐: c# - C# 和 C++ 中的可选参数
文章推荐: jquery click 函数只工作了一半
文章推荐: html - 将
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com