astupidname

msg:4297413 | 7:06 am on Apr 14, 2011 (gmt 0) |
//get the xml files last modified date as a string: var lastModified = xhr.getResponseHeader('Last-Modified'); //convert it to a date object and then to integer timestamp, //number of milliseconds since jan 1, 1970 : var lastModifiedTimeStamp = new Date(lastModified).getTime(); alert(lastModified +'\n'+ lastModifiedTimeStamp); |
| You would place the above into the xhr objects onreadystatechange function definition. What you do with the info from there is up to you I guess.
|
fm86

msg:4297488 | 11:33 am on Apr 14, 2011 (gmt 0) |
Hi and thanks for the reply! Still, this just gives me the timestamp. What I need is just the URL to which the xhr was connected.
|
astupidname

msg:4297498 | 12:02 pm on Apr 14, 2011 (gmt 0) |
Sorry but you are being entirely too vague. How are we to know why you don't know to which url the xhr is connected? You make mention of an "asciispec field" but how are we to know exactly what that means? Read your mind for you? Url variable? or form field? "url to which the xhr was connected" meaning what? The xml file it's accessing? or the page from where it's running? "check if the xml file has changed" since when? A bit more clarity from you and I'm sure you're almost there...
|
fm86

msg:4297501 | 12:20 pm on Apr 14, 2011 (gmt 0) |
Well, sorry, English is not my mother tongue. Anyway, I created this xhr object and I would like to find the url of the xml to which the connection was sent so that I can run again the open function. This URL field seems to be contained in asciispec field but I can't access it. In the worst case I just put the xml url in a global variable but maybe there is a more elegant solution. The question is: in the xhr object is there a field that contains the xml's url from which the object was built? And how to access this field?
|
astupidname

msg:4297519 | 1:09 pm on Apr 14, 2011 (gmt 0) |
| The question is: in the xhr object is there a field that contains the xml's url from which the object was built? |
| Good question, and the answer is that "no" the xhr object does not contain a property or method of retrieving it's url that it either is or was last connected to. So, yes, it is necessary for you to store the url being requested in a seperate variable to access later on. As far as more elegant solutions, well the "elegantness" of them is debatable and leads to much more code than really needed. But you could create a simple object constructor which would store both the xhr and it's url: function MyXhr(url) { this.xhr = //code to get the xhr object this.url = url; } //go on to describe prototype methods which would access the xhr methods... //.... //.... var someXhr = new MyXhr('someXmlFile.xml'); //someXhr will have a 'url' property as well as an 'xhr' one
|
|
|
fm86

msg:4297556 | 1:49 pm on Apr 14, 2011 (gmt 0) |
Thanks again, now everything is clear! And the elegant solution is very cute :) Anyway, that's so weird, why wouldn't they automatically store an important information as to which xml file the object was connected? Guess there will be some interesting explanation to that. And why with firebug do I see this asciispec field containing the URL?
|
astupidname

msg:4297565 | 2:04 pm on Apr 14, 2011 (gmt 0) |
hmmm... I don't see an "asciispec" field in an xhr object in firebug here. And yes, it does seem weird. Actually.... the xhr's responseXML property, when properly populated, does contain two properties: baseURI and documentURI which are the url of the xml file. Sadly they are not present in Internet Explorer of course and can't find alternative other than "build your own" solution as above suggested.
|
|