非常简单的 ajax 请求不起作用

Very simple ajax request not working

我正在制作一个网络应用程序。我 运行 这个功能与 jquery 1.11.2 在 index.html:

$.ajax("http://localhost/index.html")
    .done(function () {
        console.log("success");
    })
    .fail(function () {
        console.log("fail");
    });

它工作正常。我用另一个文件试试:

$.ajax("http://localhost/online.html")
    .done(function () {
        console.log("success");
    })
    .fail(function () {
        console.log("fail");
    });

我收到此错误消息:

GET http://localhost/online.html net::ERR_FAILED

online.html 在同一个文件夹中,它包含:

<!DOCTYPE html>
<html>
<head lang="en">
    <title>Picture Viewer</title>
</head>
<body>

</body>
</html>

为什么不起作用?

谢谢。

我正在使用 manifest.mf 构建一个网络应用程序,即使设备无法访问互联网也能正常工作。

如果我在 manifest.mf 中添加 online.html 它有效,我不明白为什么。现在知道如何检查浏览器是在线还是离线,用这个方法请求总是成功的。

所以我找到了我最初问题的答案,感谢您的帮助。

编辑: 如果我将 online.html 放入 manifest.mf 的 NETWORK 列表中仍然有效,但看起来浏览器仍将其存储在缓存中。

编辑 2: 如果我请求 .php 页面而不是请求 .html 内容,最终工作正常。