OtagoHarbour Posted April 30, 2013 Share Posted April 30, 2013 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. Link to comment Share on other sites More sharing options...
jeffman Posted April 30, 2013 Share Posted April 30, 2013 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" Link to comment Share on other sites More sharing options...
OtagoHarbour Posted April 30, 2013 Author Share Posted April 30, 2013 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. Link to comment Share on other sites More sharing options...
jeffman Posted April 30, 2013 Share Posted April 30, 2013 (edited) 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 April 30, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
OtagoHarbour Posted April 30, 2013 Author Share Posted April 30, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now