0

I use this loop to read some urls to read their modified time:

for (var e in arr) {
        nodename=arr[e].hostname;
        node_json="/nodes/"+nodename;
        html +='<a href="'+node_json+'" target="_blank" id="host_'+nodename+'">data</a>';
        xhr[e] = $.ajax({
            url: node_json,
            success: function(response) {
                $('#host_'+nodename).append(xhr[e].url+": last modified: " + xhr[e].getResponseHeader("Last-Modified"));
            }
        });

    }

This already works a bit, I get calls to all node-files, and in Firebug, I can see the different nodified times in the header of the calls.

But in my code I only get the last line modified with all results.

How can I call each id #host_'+nodename in each ajax call to add the right answer to the right position?

source of the AJAX call: Get the modified timestamp of a file with javascript


EDIT:

I tried this now:

        xhr = $.ajax({
            url: node_json,
            success: (function(nn) {
                $('#host_'+nn).append("last modified: " + xhr.getResponseHeader("Last-Modified"));
            })(nodename)
        });

But that gives:

ReferenceError: xhr is not defined
$('#host_'+nn).append("last modified: " + xhr.getResponseHeader("Last-Modified")...

Community
  • 1
  • 1
rubo77
  • 19,527
  • 31
  • 134
  • 226

0 Answers0