How to pass array parameters to the background in jquery easyUI (transfer)

In the development process, we may often encounter the need to delete records in batches. If we are using easyUI+struts2, let's see how we do it. Although the problem is relatively small, it is sometimes quite annoying.

 

[javascript]  view plain copy  
 
  1. // delete  
  2. function batchDelete() {  
  3.     var checks = $('#firmresult').datagrid('getChecked');  
  4.     if(checks.length==0){  
  5.         $.messager.alert( 'Prompt' , 'Please select the record to delete.' , 'warning' );  
  6.     }else{  
  7.         $.messager.confirm( 'Prompt' 'Are you sure you want to delete these records?' function (r){  
  8.             if (r){  
  9.                 var  firmIds = [];  
  10.                 for (var i = 0; i < checks.length; i++) {  
  11.                     var id = checks[i]['userId'];  
  12.                     firmIds.push(id);  
  13.                 }  
  14.                 var userType = $("#userType").combobox('getValue');  
  15.                 var  params =  
  16.                         'firmQueryBean.userIds':firmIds,'firmQueryBean.userType':userType  
  17.                         };  
  18.                 //If the parameter contains an array, you must serialize the parameter before the background can receive it  
  19.                 var  ps = $.param(params,  true ); //This is the key, we serialize the parameters and then pass them to the background, otherwise the background will never receive the data we pass  
  20.                 $.post("deleteFirmInfos.action", ps,  
  21.                    function(data){  
  22.                         if(data && data.suc){  
  23.                             $.messager.alert( 'Prompt' , 'Deletion successful!' , 'info' , function (){  
  24.                                 subSerach();  
  25.                             });  
  26.                         }else{  
  27.                             $.messager.alert( 'Prompt' , 'Deletion failed.' , 'error' );  
  28.                         }  
  29.                    }, "json");  
  30.             }  
  31.         });  
  32.     }  
  33. }  

Well, without further ado, just a little bit of attention. Happy IT friends!

 

View original >>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326515433&siteId=291194637