Cross origin resource sharing (CORS) allows resources from a web server to be accessed from a web page on another domain. The XMLHttpRequest level 2 specification added support for making cross domain requests but it should be noted that this specification is still a working draft. Traditionally I have always made cross domain requests from sites in a two stage process: 1) make a request to the server hosting the local domain for some data which then 2) makes the cross domain request, receives the response and returns this to the client. Now this process has merits, if you are hitting an external API chances are the service providers won’t be too impressed with you making a request for each user that visits your site and may even limit this. I wrote a nice little PHP class that can be used to avoid this by caching results locally but I’m going to pretend this isn’t an issue, just for today.
I’ve been experimenting with the FileSystem API in Chrome over the last couple of weeks and thought I’d share my musings with a little demo of a file syncing system that I am thinking of using in an application where the user can download a copy of the file, work on it offline and then sync it when connected again. In this post I just want to show the pull side of the sync where the file is downloaded and replicated in the local file system (within the browser) and I’ll follow up with a second post showing the silent sync with the server (push and pull based on last edit timestamp) once I have that part working.
So a while ago a messed about with the File API and FormData with the XMLHttpRequest Level 2 spec which enables the transfer of binary data and tracking of the upload progress through the XMLHttpRequestUpload object – awesome. I was blown away when I first started messing about with this stuff and support for it now seems to be a little more wide spread, nothing in IE or Opera as of yet but you know life goes on. What I did start to do was abstract some of the code I was messing about with into a little module aptly named xhr2-lib which I’ve grown a bit since and would like to share and hopefully get some feedback.
jNavigate is a powerful jQuery plugin that enables you to build single page sites using dynamic content areas powered by Ajax technologies simply and quickly. Turn your website’s hyperlinks into triggers that load page content dynamically reducing the load on your web server while enhancing your users browsing experience.
This plugin has had a rewrite and can now be found at the official jNavigate website