Jump to content
Sign in to follow this  
OtagoHarbour

loadXMLDoc loads unmodified version of modified XML file

Recommended Posts

I used loadXMLDoc to load an XML file onto my web page. I then saved different contents to a file of the save name. When I reloaded the file with loadXMLDoc, I got the original contents instead of the new contents. I deleted the file and then save the new contents to the file with the same name. Reloading still gave me the old contents. I then changed the name of the file. This time loading the file with loadXMLDoc gave me the new contents. Does loadXMLDoc remember the contents that was loaded from a file with a given name and not bother reloading the contents if I present it with a file of the same name albeit different contents? After modifying the file, I looked at the XML code and the contents were modified after the first modification.

Share this post


Link to post
Share on other sites

It sounds like the original doc is being cached. If you are using the GET request change it to POST. On the server side, you might send out these headers before sending your data: "Cache-Control: no-cache, must-revalidate""Pragma: no-cache"

Share this post


Link to post
Share on other sites
It sounds like the original doc is being cached. If you are using the GET request change it to POST. On the server side, you might send out these headers before sending your data: "Cache-Control: no-cache, must-revalidate""Pragma: no-cache"
Sorry. I should have mentioned that I am doing everything in JavaScript with some HTML. However you are certainly right about the caching causing the problem. I put the following code
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /><meta http-equiv="Pragma" content="no-cache" />

in the head section of index.html and that appears to have solved the problem. Thank you very much for you help,Peter.

Share this post


Link to post
Share on other sites

I'm glad it helped. I did know you were doing JavaScript because you were using an AJAX object. The AJAX object has a place to specify GET or POST. It might still be worth looking at. If you borrowed the loadXMLDoc function here, notice that it's preprogrammed with GET. It doesn't have to be; and if I understand your situation, it probably should not be. Any server request that changes data on the server should be a POST request.

Edited by Deirdre's Dad

Share this post


Link to post
Share on other sites
I'm glad it helped. I did know you were doing JavaScript because you were using an AJAX object. The AJAX object has a place to specify GET or POST. It might still be worth looking at. If you borrowed the loadXMLDoc function here, notice that it's preprogrammed with GET. It doesn't have to be; and if I understand your situation, it probably should not be. Any server request that changes data on the server should be a POST request.
Yes. That was the problem. Thanks again.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...