Reload TSV file without refreshing page

I searched for a day or 2 answers to this question, but have not found it yet. I have an external application that periodically modifies a TSV file (adding data). I use an example of a basic chart to display data, and it looks very good:

enter image description here

Now I want the data to be updated when the TSV file is updated. I want to be able to set automatic updating of the data that it extracts from the tsv file, and re-populates the graph without refreshing the entire page.

I tried to just wrap the current code in a function and call setInterval for that function, but the data remains the same every time (perhaps because it is cached?).

Ideally, a solution to this would be a function that you can call to update whenever you want (based on a custom event, timer, whatever).

Any ideas, links or suggestions for alternative ways to achieve the same goal will be greatly appreciated!

As a bonus question: I understand that D3 may not be the right choice for this kind of Psudo-Real-Time data display. Are there other packages that are more amenable to this? The data-generating application is a C # application (if that matters).

Edit: As an additional explanation, imagine this example, but with data read from the file: http://mbostock.github.com/d3/tutorial/bar-2.html

+4
source share
1 answer

If you make an Ajax call to retrieve data from the server, and you think caching is a problem, you can try iterating over the cache by setting the cache parameter in jquery ajaxSetup to false anywhere in your code:

 $.ajaxSetup({cache: false}); 

From the docs:

If set to false, this will cause the requested pages to not be cached by the browser. Note. Setting the cache to false will only work correctly with HEAD and GET requests. It works by adding "_ = {timestamp}" to the GET parameters. the parameter is not required for other types of requests, with the exception of IE8, when POST is done for a URL that is already requested by GET.

0
source

All Articles