Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Last modified date of local file. JavaScript

In javaScript, currently reading xml files stored in %appdata% using jQuerys $.ajax function. As the file is in %appdata% my javaScript has access to read and write the file.

Example:

/**
* 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
        });
}

Is it possible using jQuery or plain javaScript to get the files 'last modified' date?

like image 473
User2 Avatar asked Oct 21 '25 00:10

User2


1 Answers

request.getResponseHeader("Last-Modified"); will return you the last-modified date

Use it in the success callback:

success: function(data, textStatus, request){
    var lastModified = request.getResponseHeader("Last-Modified");
 }
like image 193
mohamedrias Avatar answered Oct 23 '25 15:10

mohamedrias