javascript - jQuery .each best practice to format and send via ajax -


what best practice run .each , send value array via ajax.

 $( ".sortable li" ).each(function( index ) {       console.log($(this).data("trackid"));  }); 

this output in console window 11,2,45,23,4,31.

well use push method add id's array. i've posted array php , works well.

 var thearray = [];  $( ".sortable li" ).each(function( index ) {      thearray.push($(this).data("trackid"));  });   // send via ajax  $.post(url,{ids:thearray},function(response){      // code handle response  }); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -