本地文件的上次修改日期.JavaScript的

Use*_*er2 2 javascript ajax jquery last-modified

在javaScript中,当前正在读取%appdata%使用jQuerys $.ajax函数存储的xml文件.由于该文件在%appdata%我的javaScript中有访问权限,可以读写该文件.

例:

/**
* Read a foo.
*/
function readFoo() {
    var xmlFile = "../foo/bar.xml";

        $.ajaxSetup({cache: false});
        $.ajax({
            type: "GET",
            async: true,
            timeout: 5000,
            url : xmlFile,
            dataType : "xml",
            success: parseFoo,
            error: reportFooFail
        });
}
Run Code Online (Sandbox Code Playgroud)

是否可以使用jQuery或普通的javaScript来获取文件的"上次修改"日期?

moh*_*ias 8

request.getResponseHeader("Last-Modified"); 将返回最后修改日期

在成功回调中使用它:

success: function(data, textStatus, request){
    var lastModified = request.getResponseHeader("Last-Modified");
 }
Run Code Online (Sandbox Code Playgroud)