wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes XML loading - not getting refreshed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "XML loading - not getting refreshed" Watch "XML loading - not getting refreshed" New topic
Author

XML loading - not getting refreshed

Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
I have a small hitch in reading the contents of an XML file..
the following code reads the contents properly. But the contents are refreshed dynamically and everytime it gets refreshed the loading in javascript doesnt get resfreshed. It take some time.


xmlDoc.load("xmls/messageXML.xml");
var doc=xmlDoc.documentElement;
if(doc!=null)
{
alert(doc.childNodes[0].childNodes[0].text);
}
[ August 14, 2006: Message edited by: Bear Bibeault ]
Liu Zhixiang
Ranch Hand

Joined: Aug 12, 2006
Posts: 32
function abcd() {
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.load("1.xml");
var doc=xmlDoc.documentElement;
if(doc!=null)
{
alert(doc.childNodes[0].childNodes[0].text);
}
}
setInterval("abcd()",5000);
[ August 14, 2006: Message edited by: Liu Zhixiang ]

I Think Therefore I Am
Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
yes i tried this with 2000(2 secs) but its taking 2 second which is costly.

And moreover when the content of the XMl changes why the XMl loding doesnt take place in javascript?
Liu Zhixiang
Ranch Hand

Joined: Aug 12, 2006
Posts: 32
Because the xmlDoc.load() is a method to get the XML's current value ,which isnt a import
[ August 14, 2006: Message edited by: snowwolf ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"snowwolf",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted, often without warning

thanks,
Dave
Liu Zhixiang
Ranch Hand

Joined: Aug 12, 2006
Posts: 32
I'm sorry!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

No problems
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It is called your browser is caching the document. Read this: http://radio.javaranch.com/pascarello/2005/10/21/1129908221072.html

Eric
Liu Zhixiang
Ranch Hand

Joined: Aug 12, 2006
Posts: 32
Eric Pascarello,3Q
"+Date()" appended to the request URL will be safer.
I mistake the meaning of TOP
Sorry
Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
Thank you very much for all your replies.
But my problem is no caching of data due to resuests in Ajax but XML reading object...

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("xmls/messageXML.xml");
var doc=xmlDoc.documentElement;
alert(doc.childNodes[0].childNodes[0].text);

Im getting the cache problem with this XMl loading object...
So a code to clear the chache of this object is reuired

thanks in advance
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It is the same thing here....

append the date to the name of the XML document.

Eric
Ayyappan Selvaraj
Ranch Hand

Joined: Sep 20, 2004
Posts: 63
yes thanks for the ideas that you gave.. its working now...

And one more thing I want to know, before using the XML system file method in Ajax, I used to write XML content to the response object in the Java coding and read it in the Javascript. But when reading response object as

var responseXML = req.responseXML;
var details = responseXML.getElementsByTagName("details")[0];

I got null object at the second line...

So do you have any idea what would be the error there and can you suggest me which one is the best method to get data ufing Ajax... through response object or file system...and why?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
this line should read
var responseXML = req.responseXML.documentElement;

If the getElementsByTagName does not work, than that means the XML document coming back is not structured correctly. Open up the document directly into the browser and see if it gives error messages.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML loading - not getting refreshed