如何在javascript中从目录中选择最新的txt文件

I want to select the most recently modified file from my server using javascript.

This is the code in my js files:

$.get('Dropbox/geo/sites/GC_ROOM/hassayampa.txt', function(data){   
        // Split the lines
        var lines = data.split('
');   
        // Iterate over the lines and add categories or series
        $.each(lines, function (lineNo, line) {
            var items = line.split('\t');
            if(lineNo !== 0) {
               var x = + new Date(items[0]),
                    primout = parseFloat(items[3] / 10.0),
                    secout = parseFloat(items[5] / 10.0);
                if(!isNaN(primout) && !isNaN(secout)){
                    options.series[0].data.push([x,primout]);
                    options.series[1].data.push([x,secout])
                }
            }
        });
        new Highcharts.Chart(options); // this is now in the $.get callback function
    });

Here is coding from the index.php file that views the js files:

<body width="100%">
    <script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script>
    <script src="https://geoinc.org/css/GEOREMCO/graph/highcharts.js"></script>
    <script src="https://geoinc.org/css/GEOREMCO/graph/exporting.js"></script>
    <script src="monitor/SiteData/Data/Lane_Metals/GRAPH/LANE_METALS.js" type="text/javascript"></script>
    <script src="monitor/SiteData/Data/Lane_Metals/GRAPH/LOVELAND.js" type="text/javascript"></script>
    <script src="monitor/SiteData/Data/Lane_Metals/GRAPH/TEST.js" type="text/javascript"></script>
    <script src="monitor/SiteData/Data/Lane_Metals/GRAPH/APPLES.js" type="text/javascript"></script>
    <script src="monitor/SiteData/Data/Lane_Metals/GRAPH/EXAMPLE.js" type="text/javascript"></script>
    <script src="monitor/SiteData/Data/Lane_Metals/GRAPH/FRUIT.js" type="text/javascript"></script>
    <table border="0" cellspacing="5" cellpadding="0" width="10%" bgcolor="#E8E8E8">
        <tr>   
            <th><div id="TEST" style="width: 900px; height: 300px;"></div></th>
            <th><div id="EXAMPLE" style="width: 900px; height: 300px;"></div></th>
        </tr>
        <tr>
            <td><div id="LANE_METALS" style="width: 900px; height: 300px;"></div></td>
            <td><div id="FRUIT" style="width: 900px; height: 300px;"></div></td>
        </tr>
        <tr>
           <td><div id="LOVELAND" style="width: 900px; height: 300px;"></div></td>
           <td><div id="APPLES" style="width: 900px; height: 300px;"></div></td>
        </tr>
    </table>
</body>

Thanks again everyone!

Your best solution for this would be to have a JavaScript GET request to your PHP application that handles access to your Dropbox.

From what you explained your Dropbox is only visible serverside and you want to expose your TXT files client side, to solve your current problem add a method, PHP side, to handle file access to your dropbox and expose it so your client side JavaScript can request the contents from your PHP application.