includes/clientside/static/acl.js
changeset 259 112debff64bd
parent 174 d74ff822acc9
child 292 704e1d3ca378
--- a/includes/clientside/static/acl.js	Wed Dec 12 21:46:28 2007 -0500
+++ b/includes/clientside/static/acl.js	Sat Dec 15 18:10:14 2007 -0500
@@ -27,6 +27,17 @@
   ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
       if(ajax.readyState == 4)
       {
+        var response = String(ajax.responseText + '');
+        if ( response.substr(0, 1) != '{' )
+        {
+          handle_invalid_json(ajax.responseText);
+          return false;
+        }
+        try {
+          data = parseJSON(ajax.responseText);
+        } catch(e) {
+          handle_invalid_json(ajax.responseText);
+        }
         __aclBuildWizardWindow();
         groups = parseJSON(ajax.responseText);
         if ( groups.mode == 'error' )
@@ -307,10 +318,16 @@
   ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
       if(ajax.readyState == 4)
       {
+        var response = String(ajax.responseText + '');
+        if ( response.substr(0, 1) != '{' )
+        {
+          handle_invalid_json(ajax.responseText);
+          return false;
+        }
         try {
           data = parseJSON(ajax.responseText);
         } catch(e) {
-          aclDebug(e+"\n\nResponse:\n"+ajax.responseText);
+          handle_invalid_json(ajax.responseText);
         }
         aclDataCache = data;
         switch(data.mode)
@@ -470,7 +487,7 @@
             aclDebug(data.text);
             break;
           default:
-            alert("Invalid JSON response from server\nMode: "+data.mode+"\nJSON string: "+ajax.responseText);
+            handle_invalid_json(ajax.responseText);
             break;
         }
       }