function CheckRotateJob(id,job_id) { $.ajax( { type: 'POST', data: '&job_id='+job_id, url: '/checkrotatejob', success: function(data) { if( data.finished ) { $('#s'+id).hide() $('#'+id).find('img.thumb').attr('style', 'filter: color(100%);' ); $('#'+id).addClass('entry') $('#'+id).find('.thumb').attr('src', 'data:image/jpeg;base64,'+data.thumbnail) return false; } else { setTimeout( function() { CheckRotateJob(id,job_id) }, 1000,id, job_id ); } }, } ) } function Rotate(amt) { $('.highlight').each(function( id, e ) { post_data = '&amt='+amt+'&id='+e.id {# send rotate for this image, grayscale the thumbmail, add color spinning wheel overlay, and start checking for job end #} $.ajax({ type: 'POST', data: post_data, url: '/rotate', success: function(data){ $('#'+e.id).find('img.thumb').attr('style', 'filter: grayscale(100%);' ); $('#'+e.id).removeClass('entry'); $('#s'+e.id).show(); CheckRotateJob(e.id,data.job_id); return false; } }) } ) }