Search code examples
javascriptajaxsvncronsame-origin-policy

Approach for fetching files from svn server using ajax


I am building a simple web page that will run on a computer connected to a large TV, displaying some relevant information for whomever passes it.

The page will (somehow) fetch some text files which are located on a svn server and then render the them into html.

So I have two choices how to do this:

  1. Set up a cron job that periodically checks the svn server for any changes, and if so updates the files from svn, and and (somehow) updates the page. This has the problem of violating the Access-Control-Allow-Origin policy, since the files now exist locally, and what is a good way to refresh a page that runs in full screen mode?

  2. Make the javascript do the whole job: Set it up to periodically ajax request the files directly from the svn server, check for differences, and then render the page. This somehow does not seem as elegant.

Update The Access-Control-Allow-Origin policy doesn't seem to be a problem when running on a web server, even though the content is on the same domain..


Solution

  • What I did in the end was a split between the two:

    1. A cron job update the files from svn.
    2. The javascript periodicly requests the files using window.setInterval and turning on the ifModified flag on the ajax request to only update the html if a changed had occured.