【问题标题】:net::ERR_FILE_NOT_FOUND: Working on PhpStorm server but not working in the browsernet::ERR_FILE_NOT_FOUND:在 PhpStorm 服务器上工作但在浏览器中不工作
【发布时间】:2019-08-26 07:11:45
【问题描述】:

我正在测试一个 html 网页,但在浏览器中它无法正常工作。它无法加载:

src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"

这是错误:

获取文件://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js net::ERR_FILE_NOT_FOUND

我想质疑同一个 html 网页中的另一个错误,如下所示:

Uncaught ReferenceError: $ is not defined at files.html:337

这是脚本:

$('.toggle').click(function (e) {
e.preventDefault();
var $this = $(this);
if ($this.next().hasClass('show')) {
    $this.next().removeClass('show');
    $this.next().slideUp(350);
} else {
    $this.parent().parent().find('li .inner').removeClass('show');
    $this.parent().parent().find('li .inner').slideUp(350);
    $this.next().toggleClass('show');
    $this.next().slideToggle(350);
}
});

【问题讨论】:

  • 你是怎么打开那个页面的?什么网址?请注意错误的file:// - 看起来您已经通过file:// 打开它.. 所以我认为错误是意料之中的,如果您想以这种方式打开它,您需要使用完整的url (https://cdn...)。

标签: javascript html phpstorm


【解决方案1】:

代替
src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"
使用
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 2021-07-14
    • 2021-06-09
    相关资源
    最近更新 更多