Question on efficiency of script

Question on efficiency of script

Hello:

I've just finished writing a routine to do the following:

  1. Use $.post to grab a dynamically produced php table and display it in a "group" container. The table shows 1 line for each group member, and their privileges.
  2. Use $(".grpBK_O1 select").map(function(){ to iterate through the resulting member table and grab the value of the privileges <select object.
    • Assign values to variables that will be pushed into an array
  3. Use $.each(memberID, function() {    to test and process EVERY memberID
    • Use $.grep(grpPrivilege_array, function(v,i) { within the $.each() to figure out if there are duplicates in the array - BEFORE pushing
      • Use if (result=='') to do an array push
What bothers me - from an efficiency perspective - is how many different procedures I'm using to accomplish this. Following is the actual script:

  1.         if (grpCheck == true)
  2.         {
  3.         // Open Group detail section so user can assign privileges
  4.         // ### grab data (group members and privileges) and display in detail section
  5.             $.post("ol_list_grpMembers_O1.php",{bind_grpID:grp_ID},function(data){
  6.                 $(grpContainer).removeClass('ol_hidden').addClass('ol_shownTR');
  7.                 $(grpContainer + ">td").html(data);
  8.                     // iterate through the <select objects
  9.                     values = $(".grpBK_O1 select").map(function(){
  10.                         // now set variables for assembling the array
  11.                         row_ID = this.id; // this.id is jQuery for javascripts: $(this).attr('id');
  12.                         memberID = row_ID.split("_").pop(-1);
  13.                         grpPrivilegesID = $(this).val();
  14.                             // Use $.each to test each memberID against grpPrivilege_array for possible duplicates.                   
  15.                             $.each(memberID, function() {                       
  16.                                 // Use Grep to find duplicates.
  17.                                 var result = $.grep(grpPrivilege_array, function(v,i) {
  18.                                     return v['participantID'] === memberID;
  19.                                 });
  20.                                     // If the grep result is empty '', then push memberID and grpPrivilegesID into grpPrivilege_array
  21.                                     if (result=='')
  22.                                     {
  23.                                         grpPrivilege_array.push({participantID:memberID, PrivID:grpPrivilegesID});
  24.                                     }
  25.                             });   
  26.                     return grpPrivilege_array;
  27.                     }).get();
  28.                     console.log("result array: " + JSON.stringify(grpPrivilege_array));       
  29.             });
  30.            
  31.         // Set background color of row
  32.         $(this).closest('tr').css('background-color', '#85a888');
  33.         }
jQuery is newish to me - but I've decades of experience in other languages. And it is a bit concerning to me that I'm nesting so many different types of functions to accomplish the goals outlined above.

Is there a more efficient way to accomplish my goals?

Thanks in advance: Pavilion