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();
            $cartUrl = $this->_url->getUrl('checkout/cart/index');
            $this->logger->info("No data");   

It's not redirecting to checkout

I'm using \Magento\Framework\UrlInterface $url

1 Answer 1


in your ajax success function you can use jquery code

for e.g. window.location.href='your checkout url';

  • thanks! I don't know why I tried to do it from controller. May 4, 2021 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.