I'm trying to redirect a form to checkout after clicking ajax submit request.
I'm able to reach the controller, but I can't redirect to checkout.
Here is my code:
public function execute(){
$post = $this->getRequest()->getPostValue();
if($post){
$this->logger->info(print_r($post));
$cartUrl = $this->_url->getUrl('checkout/cart/index');
$this->_responseFactory->create()->setRedirect($cartUrl)->sendResponse();
exit;
}
else{
$this->logger->info("No data");
}
}
It's not redirecting to checkout
I'm using \Magento\Framework\UrlInterface $url