includes/clientside/static/enano-lib-basic.js
changeset 677 2a263b598a2b
parent 664 b164e05c5faa
child 694 43367c66d869
--- a/includes/clientside/static/enano-lib-basic.js	Tue Aug 05 13:59:06 2008 -0400
+++ b/includes/clientside/static/enano-lib-basic.js	Mon Aug 11 11:56:25 2008 -0400
@@ -235,14 +235,35 @@
   
   file = file + '.js';
   var uri = ( ENANO_JSRES_COMPRESSED ) ? scriptPath + '/includes/clientside/jsres.php?f=' + file : scriptPath + '/includes/clientside/static/' + file;
-  ajax.open('GET', uri, false);
-  ajax.send(null);
-  if ( ajax.readyState == 4 && ajax.status == 200 )
+  try
   {
-    onload_hooks = new Array();
-    eval_global(ajax.responseText);
+    ajax.open('GET', uri, false);
+    ajax.onreadystatechange = function()
+    {
+      if ( this.readyState == 4 && this.status != 200 )
+      {
+        alert('There was a problem loading a script from the server. Please check your network connection.');
+        load_hide_win();
+        throw('load_component(): XHR for component ' + file + ' failed');
+      }
+    }
+    ajax.send(null);
+    // async request, so if status != 200 at this point then we're screwed
+    if ( ajax.readyState == 4 && ajax.status == 200 )
+    {
+      onload_hooks = new Array();
+      eval_global(ajax.responseText);
+      load_hide_win();
+      runOnloadHooks();
+    }
+  }
+  catch(e)
+  {
+    alert('There was a problem loading a script from the server. Please check your network connection.');
     load_hide_win();
-    runOnloadHooks();
+    console.info("Component loader exception is shown below.");
+    console.debug(e);
+    throw('load_component(): XHR for component ' + file + ' failed');
   }
   
   loaded_components[file] = true;