var messagehideTime=null;
jQuery(document).ready(function($) {
    $('.review-status-dropdown').change(function() {
		clearTimeout(messagehideTime);
		var $this=$(this);
        var postId = $this.data('post-id');
		$this.attr('disabled',true);
        var $next = $this.siblings('.resp_text');
        $next.addClass('loader');
        var newStatus = $this.val();
        jQuery("span",$next).text("Please wait...");
        $.ajax({
            url: ajaxurl,
            type: 'POST',
            data: {
                action: 'update_review_status',
                post_id: postId,
                new_status: newStatus,
            },
            success: function(response) {
                // Optionally handle success response
				$next.removeClass('loader');
				$this.removeAttr('disabled');
                jQuery("span",$next).text(response);
				// Clear the text content after 5 seconds
				
				messagehideTime=setTimeout(function() {
					jQuery("span",$next).text('');
				}, 5000);
				
            },
            error: function(error) {
				$this.removeAttr('disabled');
                // Optionally handle error response
                
            }
        });
    });
});
