简体   繁体   English

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

[英]What is meaning of error 404 (Not Found)

I have created a small web site, where I am showing some data, which I get from an API (JSON data type).我创建了一个小型网站,我在其中展示了一些数据,这些数据是从 API(JSON 数据类型)获取的。 In my console I am getting these two errors:在我的控制台中,我收到了这两个错误:

1) GET http://fonts.gstatic.com/s/opensans/v10/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2 404 (Not Found) 1)获取http://fonts.gstatic.com/s/opensans/v10/u-WUoqrET9fUeobQW7jkRRJtnKITppOI_IvcXXDNrsc.woff2 404(未找到)

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.该站点仍在运行并显示所有数据。

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 是无效的。

ajax is asynchronous request means that you cant return it when it is in progress so if you want return any thing from ajax you must call it's events like success and error .so your code must like below: ajax 是异步请求意味着你不能在它进行时返回它,所以如果你想从 ajax 返回任何东西,你必须调用它的事件,如successerror你的代码必须如下所示:

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

        success: function(data){
          return data;
        },

        error: function(data){
          console.log(data.responseText);
        }
    });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM