Flink Posted June 5, 2015 Share Posted June 5, 2015 Hello there dear people of this awesome forum! I am hoping you can help me with a problem I have:Let's say my game has these files:main.jsplayer.jshud.jsIf hud.js is missing the game won't start. I need a way, so that this would only not show the hud but still execute the rest of the game.Any tips are appreciated, thanks in advance! Link to comment Share on other sites More sharing options...
rich Posted June 5, 2015 Share Posted June 5, 2015 The only real way to do this would be to use something like requireJS, but even then this is a very strange requirement. Whatever your reason for maybe having a missing file, I would try my best to find an alternative / more sensible solution. Link to comment Share on other sites More sharing options...
pauser Posted June 5, 2015 Share Posted June 5, 2015 Make an ajax request to your file, looking something like this:$.ajax({ url: "./js/hud.js", success: function(result){ console.log("file is there"); }, error: function(){ console.log("file is not there"); }, type:GET, dataType:"text"}); Link to comment Share on other sites More sharing options...
Flink Posted June 6, 2015 Author Share Posted June 6, 2015 Thanks for the answers. I will look into Ajax.I am trying to build a programming learning environment. The player types some code in a web based IDE. These produced files shall then land in the game. So the player basically extends a basic game. Link to comment Share on other sites More sharing options...
Recommended Posts