473,396 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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: prayinjamat.com
Feb 15 '09 #1
3 2437
gits
5,390 Expert Mod 4TB
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
@gits
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
gits
5,390 Expert Mod 4TB
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

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

Similar topics

4
by: Martin | last post by:
This is probably more of an HTML question than PHP. Perhaps someone here can answer or point me to a proper newsgroup. How can I force the browser to reload an image from the server? I have a...
0
by: jacob c. | last post by:
When I request a URL using urllib2, it appears that urllib2 always makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use the "If-None-Match"/"ETag" HTTP headers to conserve...
5
by: Derek Ross | last post by:
Hello, Say I have a server that's saving the CPU temperature to 'temperature.js' once a second. The contents of the file is one single line: var temperature = "35.5"; And it changes as...
1
by: zdhiu | last post by:
Hi javascript gurus, I have a simple html file (simple.html) with javascript. In html page there is sentence from variable defined in .js file (myFirst.js). Once I reload another .js file...
4
by: Mark Anderson | last post by:
Sorry if this is borderline JS vs. HTML. I ask here as the success/failure if the resulting JS is key. I've a small external .JS library that allows a non code-savvy user to occasionally update...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
4
by: Patrick C | last post by:
Someone suggested I use reload when trying to reopen a script i've written (the suggestion was made in response to the problem ive reposted below) however when i do reload(modolename) i only get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.