includes/clientside/static/acl.js
changeset 259 112debff64bd
parent 174 d74ff822acc9
child 292 704e1d3ca378
equal deleted inserted replaced
258:8be996c3740d 259:112debff64bd
    25   params = toJSONString(params);
    25   params = toJSONString(params);
    26   params = ajaxEscape(params);
    26   params = ajaxEscape(params);
    27   ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
    27   ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
    28       if(ajax.readyState == 4)
    28       if(ajax.readyState == 4)
    29       {
    29       {
       
    30         var response = String(ajax.responseText + '');
       
    31         if ( response.substr(0, 1) != '{' )
       
    32         {
       
    33           handle_invalid_json(ajax.responseText);
       
    34           return false;
       
    35         }
       
    36         try {
       
    37           data = parseJSON(ajax.responseText);
       
    38         } catch(e) {
       
    39           handle_invalid_json(ajax.responseText);
       
    40         }
    30         __aclBuildWizardWindow();
    41         __aclBuildWizardWindow();
    31         groups = parseJSON(ajax.responseText);
    42         groups = parseJSON(ajax.responseText);
    32         if ( groups.mode == 'error' )
    43         if ( groups.mode == 'error' )
    33         {
    44         {
    34           alert(groups.error);
    45           alert(groups.error);
   305   params = toJSONString(params);
   316   params = toJSONString(params);
   306   params = ajaxEscape(params);
   317   params = ajaxEscape(params);
   307   ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
   318   ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() {
   308       if(ajax.readyState == 4)
   319       if(ajax.readyState == 4)
   309       {
   320       {
       
   321         var response = String(ajax.responseText + '');
       
   322         if ( response.substr(0, 1) != '{' )
       
   323         {
       
   324           handle_invalid_json(ajax.responseText);
       
   325           return false;
       
   326         }
   310         try {
   327         try {
   311           data = parseJSON(ajax.responseText);
   328           data = parseJSON(ajax.responseText);
   312         } catch(e) {
   329         } catch(e) {
   313           aclDebug(e+"\n\nResponse:\n"+ajax.responseText);
   330           handle_invalid_json(ajax.responseText);
   314         }
   331         }
   315         aclDataCache = data;
   332         aclDataCache = data;
   316         switch(data.mode)
   333         switch(data.mode)
   317         {
   334         {
   318           case 'seltarget':
   335           case 'seltarget':
   468             break;
   485             break;
   469           case 'debug':
   486           case 'debug':
   470             aclDebug(data.text);
   487             aclDebug(data.text);
   471             break;
   488             break;
   472           default:
   489           default:
   473             alert("Invalid JSON response from server\nMode: "+data.mode+"\nJSON string: "+ajax.responseText);
   490             handle_invalid_json(ajax.responseText);
   474             break;
   491             break;
   475         }
   492         }
   476       }
   493       }
   477     });
   494     });
   478 }
   495 }