javascript $.getScript 返回状态已取消,应用程序不执行回调函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8227422/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
$.getScript returns status canceled and the application does not execute the callback function?
提问by ridermansb
Environment
环境
To automate the compression and the junction of my js files, I use thistool.
为了自动压缩和连接我的 js 文件,我使用了这个工具。
Once installed and configured, the code below returns a js compressed and concatenated with all the JS folder project
安装和配置后,下面的代码返回一个 js 压缩并与所有 JS 文件夹连接 project
<script src="@BundleTable.Bundles.ResolveBundleUrl("~/Scripts/pages/project-projectPhotos/js")"></script>
<script src="@BundleTable.Bundles.ResolveBundleUrl("~/Scripts/pages/project-projectPhotos/js")"></script>
Problem
问题
In my page, have the following code:
在我的页面中,有以下代码:
loaderPhotosPage = function(url) {
$.getScript('/Scripts/pages/project-projectPhotos/js', function() {
alert(url); //This code is not executed!! Here's the problem;
});
};
alert
is never executed!
alert
永远不会被执行!
Tests
测试
To simulate a test tool using Google Chrome Developer Tools, I got the following results:
为了使用 Google Chrome Developer Tools 模拟测试工具,我得到了以下结果:
Code executed on Google Chrome Developer
在 Google Chrome Developer 上执行的代码
Look at the console, and the header. The execution is very successful!
查看控制台和标题。执行非常成功!
Now the preview result
现在预览结果
The HTTP status is as canceled, why? Yet the code in the console was running normally (text: success)
HTTP 状态为已取消,为什么?但是控制台中的代码运行正常(文本:成功)
I put the js file complete at thislink.
我把 js 文件完整地放在这个链接上。
Another test:
另一个测试:
See the get, with the link of the script is running normally!
看到get,用链接的脚本运行正常!
Thanks for the help!
谢谢您的帮助!
采纳答案by RichB
The canceled status is an issue with current dev channel Google Chrome. It has been fixed upstream and will propagate to the dev channel accordingly.
取消状态是当前开发频道 Google Chrome 的一个问题。它已在上游修复,并将相应地传播到开发频道。