$.ajax with $.each

$.ajax with $.each

I have several divs equal with different values ​​and I'm trying to get all the id like this:

  1. $(".compartilhamento").each(function(){
  2.       var compartilhamentos_id4 = $(this).attr("id");
  3.       var compartilhamentos_id3 = compartilhamentos_id4.split("_");
  4.       var compartilhamentos_id2 = compartilhamentos_id3[2];
  5. });

and now I have all the ids in a var.. I use this var and sends it to a php file.. how i do it ? 

  1. $.ajax({
  2. url: "ajax/load.php",
  3. type: "post",
  4. dataType: "json",
  5. cache: false,
  6. data:
  7. {
  8. compartilhamentos_id2: compartilhamentos_id2 
  9. });