且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拒绝执行脚本,是否启用了严格的MIME类型检查?

更新时间:2021-10-14 21:30:42

你有一个< script> 元素试图加载一些外部JavaScript。

You have a <script> element that is trying to load some external JavaScript.

你给它的URL指向JSON文件而不是JavaScript程序。

The URL you have given it points to a JSON file and not a JavaScript program.

服务器正确报告它是JSON,因此浏览器正在使用该错误消息中止而不是尝试执行JSON作为JavaScript(这将是发生错误)。

The server is correctly reporting that it is JSON so the browser is aborting with that error message instead of trying to execute the JSON as JavaScript (which would throw an error).

可能的一个原因是你正在尝试发出Ajax请求,已经尝试过交叉来源错误通过告诉jQuery你正在使用JSONP来修复它。这仅在URL提供JSONP(JavaScript的不同子集)时才有效,而这不是。

Odds are that the underlying reason for this is that you are trying to make an Ajax request, have hit a cross origin error and have tried to fix it by telling jQuery that you are using JSONP. This only works if the URL provides JSONP (which is a different subset of JavaScript), which this one doesn't.

带有附加查询字符串参数的相同URL callback = the_name_of_your_callback_function 确实会返回JavaScript。

The same URL with the additional query string parameter callback=the_name_of_your_callback_function does return JavaScript though.