Show
Ignore:
Timestamp:
08/21/10 20:31:41 (21 months ago)
Author:
ort
Message:

Избавляемся от использования JsHttpRequest? и отдаем ответы в формате JSON

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/templates/skin/developer/actions/ActionTalk/speakers.tpl

    r923 r996  
    2222                                idTarget = element.get('id').replace('speaker_item_',''); 
    2323 
    24                                 JsHttpRequest.query( 
    25                                                 'POST '+aRouter['talk']+'ajaxdeletetalkuser/', 
    26                                                 { idTarget:idTarget,idTalk:idTalk, security_ls_key: LIVESTREET_SECURITY_KEY }, 
    27                                                 function(result, errors) { 
    28                                                         if (!result) { 
     24                                new Request.JSON({ 
     25                                        url: aRouter['talk']+'ajaxdeletetalkuser/', 
     26                                        noCache: true, 
     27                                        data: { idTarget:idTarget,idTalk:idTalk, security_ls_key: LIVESTREET_SECURITY_KEY }, 
     28                                        onSuccess: function(result){ 
     29                                                if (!result) { 
    2930                                                                msgErrorBox.alert('Error','Please try again later'); 
    3031                                                                element.getParent().fade(1); 
     
    3637                                                                element.getParent('li').destroy(); 
    3738                                                        } 
    38                                                 }, 
    39                                                 true 
    40                                 ); 
    41  
     39                                        }, 
     40                                        onFailure: function(){ 
     41                                                msgErrorBox.alert('Error','Please try again later'); 
     42                                        } 
     43                                }).send(); 
    4244                                return true; 
    4345                        } 
     
    7375                                } 
    7476                                $('talk_speaker_add').set('value',''); 
    75                                 JsHttpRequest.query( 
    76                                                 'POST '+aRouter['talk']+'ajaxaddtalkuser/', 
    77                                                 { users: sUsers, idTalk: idTalk, security_ls_key: LIVESTREET_SECURITY_KEY }, 
    78                                                 function(result, errors) { 
    79                                                         if (!result) { 
    80                                                                 msgErrorBox.alert('Error','Please try again later'); 
    81                                                         } 
    82                                                         if (result.bStateError) { 
    83                                                                 msgErrorBox.alert(result.sMsgTitle,result.sMsg); 
    84                                                         } else { 
    85                                                                 var aUsers = result.aUsers; 
    86                                                                 aUsers.each(function(item,index) { 
    87                                                                         if(item.bStateError){ 
    88                                                                                 msgErrorBox.alert(item.sMsgTitle, item.sMsg); 
    89                                                                         } else { 
    90                                                                                 addListItem(item.sUserId,item.sUserLogin,item.sUserLink,idTalk); 
    91                                                                         } 
    92                                                                 }); 
    93                                                         } 
    94                                                 }, 
    95                                                 true 
    96                                 ); 
     77                                new Request.JSON({ 
     78                                        url: aRouter['talk']+'ajaxaddtalkuser/', 
     79                                        noCache: true, 
     80                                        data: { users: sUsers, idTalk: idTalk, security_ls_key: LIVESTREET_SECURITY_KEY }, 
     81                                        onSuccess: function(result){ 
     82                                                if (!result) { 
     83                                                        msgErrorBox.alert('Error','Please try again later'); 
     84                                                } 
     85                                                if (result.bStateError) { 
     86                                                        msgErrorBox.alert(result.sMsgTitle,result.sMsg); 
     87                                                } else { 
     88                                                        var aUsers = result.aUsers; 
     89                                                        aUsers.each(function(item,index) { 
     90                                                                if(item.bStateError){ 
     91                                                                        msgErrorBox.alert(item.sMsgTitle, item.sMsg); 
     92                                                                } else { 
     93                                                                        addListItem(item.sUserId,item.sUserLogin,item.sUserLink,idTalk); 
     94                                                                } 
     95                                                        }); 
     96                                                } 
     97                                        }, 
     98                                        onFailure: function(){ 
     99                                                msgErrorBox.alert('Error','Please try again later'); 
     100                                        } 
     101                                }).send(); 
    97102                                return false; 
    98103                        }