javascript 错误 404(未找到)是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29658375/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 10:51:03  来源:igfitidea点击:

What is meaning of error 404 (Not Found)

javascript

提问by DaniKR

I have created a small web site, where I am showing some data, which I get from an API (JSON data type). In my console I am getting these two errors:

我创建了一个小型网站,我在其中展示了一些数据,这些数据是从 API(JSON 数据类型)中获取的。在我的控制台中,我收到了这两个错误:

1) GET http://fonts.gstatic.com/s/opensans/v10/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2404 (Not Found)

1)获取http://fonts.gstatic.com/s/opensans/v10/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2404(未找到)

error 1) is in my code pointing to this line of code:

错误 1) 在我的代码中指向这行代码:

<script src="https://maps.googleapis.com/maps/api/js"></script>

2) GET http://localhost/[object%20Event]404 (Not Found)

2) GET http://localhost/[object%20Event]404 (未找到)

and error 2) is in my code pointing on this line of code:

和错误 2) 在我的代码中指向这行代码:

function getData(url){
    return $.ajax({
        type: 'GET',
        dataType: 'json',
        url: url
    });
}

Any idea what these errors mean? These particular errors have no effect on the site; the site is still working and showing all data.

知道这些错误是什么意思吗?这些特定错误对网站没有影响;该站点仍在运行并显示所有数据。

回答by pingbattlespl0x

The 404 code means that the server was unable to locate the files you were looking for via GET request.

404 代码意味着服务器无法通过 GET 请求找到您要查找的文件。

You might try adding the text/javascript type to your tags, as the examples for google maps api do.

您可以尝试将 text/javascript 类型添加到您的标签中,就像 google maps api 的示例一样。

ie:

IE:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>

As far as the second problem you encountered, it looks like the url you passed into the getData() function was invalid.

至于您遇到的第二个问题,您传递给 getData() 函数的 url 似乎无效。