By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,576 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,576 IT Pros & Developers. It's quick & easy.

need to force reload of a text file when it has been modified

P: 2
here are the parameters in which i am working:
  1. i have Google Maps mashup that uses a text file to contain all the data points
  2. i use the text file because i have no experience with mysql or any database languages
  3. users may add data points to the text file database, and the additions are made by php scripts
  4. the mashup itself is written in javascript
what i am trying to solve: right now users can successfully add datapoints. but they cannot immediately see their data points on the map because the mashup uses the same copy of the database it downloaded on loading.

that text file is now out of date because of the addition, but the mashup does not know that, obviously.

right now all i can tell users to do is clear their disk cache.

my question: is there a way in javascript or PHP to force a reload of that database .txt file after the user has completed the process of adding a datapoint?

thanks in advance! you can see the site in operation here:
Feb 15 '09 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 5,390
no ... there is no real way for a server push but you may use a poll - use a setInterval() to execute a lookup for the modified file ...

kind regards
Feb 15 '09 #2

P: 2
thanks for that suggestion!

i have realized though that my initial goal won't work. yes, i do want the browser to reload a text file after the user modifies it. but the sequence of events in the scripts requires something, too.

let me explain:
1) page loads, and page calls up the text-file-database.
2) that file is parsed...
3) ...into an array of data points.

so it would not be enough to reload the text file.

i realize my goal really is to make the new datapoint accessible to the user who just inputted it.

one way to do that -- have the user reload the whole page after he adds a datapoint. the problem i have encountered is that browsers cache that old text-file-database. so even reloading the page will not force a download of the updated text file.

so new questions: is there a way to make the page download the text file each time the page loads, regardless of the browser's cache settings? or a way to stop the text file from ever being saved in the cache? -- though i need it to be in memory long enough to be parsed?

the alternative to the above -- and the above seems much easier to me intuitively -- is to have the data point added to the array. the problem is that the main page runs the map. and the script that adds data points runs in an "infowindow" -- those little popup windows you see in Google Maps and mashups. so i am not sure whether the script can add to the array in the main page. any ideas here?
Feb 15 '09 #3

Expert Mod 5K+
P: 5,390
to avoid caching you just need to add a unique url-param to the request like:

Expand|Select|Wrap|Line Numbers
  1. 'your_filename' + '?v=' + +new Date;
in case you want to do that with javascript.

when both windows run from the same domain? then the is no problem to have the array directly manipulated ... from which window to which window would be the direction? probably you juat need to store a reference to the opened window in the parent page or use the opener-reference to go down from the child to the parent.

kind regards
Feb 16 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.