for(var i=1;i<=133;i+=4){ var class_number_range = [i,i+3]; var enrollment_available = (i+3)/4; var params_to_send = {'type':'add_school_data','class_number_range':class_number_range,'enrollment_available':enrollment_available}; var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send); } var class_number_range = [137,200]; var enrollment_available = 35; var params_to_send = {'type':'add_school_data','class_number_range':class_number_range,'enrollment_available':enrollment_available}; var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send); post_data.done(function(){ console.log('done'); });