• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML loading - not getting refreshed

 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry!
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problems
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello,3Q
"+Date()" appended to the request URL will be safer.
I mistake the meaning of TOP
Sorry
 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is the same thing here....

append the date to the name of the XML document.

Eric
 
Ayyappan Selvaraj
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic