check the below code

**In controller:**

    use Magento\Framework\App\Action\Action;
    use Magento\Framework\Controller\Result\JsonFactory;
    use Magento\Framework\View\Result\PageFactory;
    use Magento\Framework\App\Action\Context;
    
    class Save extends Action
    {
     /**
         * @var Magento\Framework\View\Result\PageFactory
         */
        protected $_resultPageFactory;
    
        /**
         * @param Context     $context
         * @param PageFactory $resultPageFactory
         */
        public function __construct(
            Context $context,
            PageFactory $resultPageFactory
    
        ) {
            $this->_resultPageFactory = $resultPageFactory;
            parent::__construct($context);
    
        }
    
        public function execute()
        {
    
            $resultPage = $this->_resultPageFactory->create();
            $resultPage->getConfig()->getTitle()->prepend(__(' Success '));
    
            $block = $resultPage->getLayout()
                    ->createBlock('Softadroit\Prescription\Block\blockname') //or use default block class of magento
                    ->setTemplate('Softadroit_Prescription::Success.phtml')
                    ->toHtml();
            $this->getResponse()->setBody($block);
        }
    }