0

So I have made some games in HTML5 which are played one after another, the game changes every 5 minutes using the loadgame function with the preloadJS library. gameID is the filename of the new game to load. What happens is that if the internet is very slow then no event is triggered and the next game is never loaded.

loadgame = function() 
{
    canvas = document.getElementById("canvas");
    stage = new createjs.Stage(canvas);

    loader = new createjs.LoadQueue(false);
    loader.loadFile({src:gameID+".js", type:"javascript"}, true);   
    loader.addEventListener("complete", prehandleComplete);
    loader.addEventListener("error", handleLoadError1);
    loader.addEventListener("fileerror", handleLoadError1);
}
Condward
  • 135
  • 3
  • 13
  • I got this error using Microsoft Edge: XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3. – Condward Oct 07 '15 at 13:23

2 Answers2

0

I did a quick search on the error, and found some results indicating that there might be something in the mimetype or charset of the data that is causing the error.

Similar to the solution to the example in the post I linked to above, you can append a custom Content-Type header to any load item:

loader.loadFile({
    src:gameID+".js", 
    headers:{"Content-Type" : "application/json; charset=utf-8"}
});  

Note that you don't need the "type" property in this load item (the extension will determine that for you), nor do you need to pass true as the second argument, since that is the default value.

Community
  • 1
  • 1
Lanny
  • 11,244
  • 1
  • 22
  • 30
  • Thanks, but that problem of XMLHttpRequest happened due the file not loading at all because of timeout. – Condward Oct 07 '15 at 18:11
  • Not sure what your comment means. The info on the error indicates it needs the content type set. If you get an error that PreloadJS currently can not detect, then the file will timeout, but should not cause the 00002ef3 error. – Lanny Oct 07 '15 at 19:53
  • I think it caused it because it didn't load the file that gave the content type too. At least that error won't appear anymore since i changed the timeout to 1 minute. – Condward Oct 08 '15 at 10:21
0

That happened because of timeout on loading the file and for some reason it doesn't trigger events.

loader.loadFile({src:gameID+".js", type:"javascript", loadTimeout:"60000"}, true);  
Condward
  • 135
  • 3
  • 13