views:

48

answers:

1

I have an application which is javascript and HTML to be delivered with about 500 short (18MB) videos on 2 physical discs. I'm making an ajax request to check a file exists before displaying it, if it does not I prompt the user to insert the other disc.

  video.innerHTML = "<p class=\"no-video\">Working...</p>";
  $.ajax({
   url: "movies/"+num+".mp4",
   type: "HEAD",
   success: function(){showVideo(num);},
   error: function(){video.innerHTML = "<p class=\"no-video\">Please insert the other disk and click <a href=\"javascript:showLot("+num+")\">ok</a></p>";}
  });

This works fine in Firefox, but takes about a minute to figure out the file is actually there in IE (if the file is missing it is fast), I'm assuming this is because IE does not respect type: "HEAD" but it still should not take that long to load an 18MB file from DVD. I'll have to test more browsers next. Does anyone have any suggestions?

(would prefer not to have to re-load the HTML when the disc is swapped)

+1  A: 

Interesting thought about using HEAD with the file system. Another solution is to use some sort of a file that acts as a table of contents for what's on the disc.

fhj
I had that thought, and if nothing better appears I'll go with that. It just adds a step to the publishing process (which could be automated but probably not worth it for once a year publication)
Myster
IE and chrome failed to load the index via ajax, so we had to put a simpler solution out the door. Time ran out. (Note: Chrome was ok if we served the index via IIS)
Myster
Thanks for reporting this, and sorry it didn't work out. Another approach which I think would work is to make this file in the form of a JS file with maybe one line: var toc = new Array("file1", "file2"); and then include it in your page.
fhj
good idea, I will try and keep that up my sleeve for next year.
Myster