jQuery(function($){ $('#aigp_generate_content_images').click(function(){ let button = $(this); button.prop( 'disabled', true ); $('#aigp_content_result').html( '⏳ Generating images, please wait...' ); $.ajax({ url:aigp_content_ajax.url, type:'POST', data:{ action:'aigp_generate_content_images', nonce:aigp_content_ajax.nonce, post_id:$('#post_ID').val() }, success:function(response){ if(response.success){ $('#aigp_content_result').html( '✅ '+response.data.message ); setTimeout(function(){ location.reload(); },2000); }else{ $('#aigp_content_result').html( '❌ '+response.data ); button.prop( 'disabled', false ); } }, error:function(){ $('#aigp_content_result').html( '❌ Server error' ); button.prop( 'disabled', false ); } }); }); }); memo » Best Collections