I'm having a problem, I've placed an ajax Request in my cart, and she's doing what she has to do that is adding the product to the cart, but she does not redirect to the next page, she stands in the same place, so I added A submit function, but then add 2 products which would be what the functions has to do, how do I redirect to next screen without the submit?


            productAddToCartForm.submit = function(button, url) {
            if (this.validator.validate()) {
                var form = this.form;
                var oldUrl = form.action;

                if (url) {
                   form.action = url;
                var e = null;

                url = jQuery('#product_addtocart_form').attr('action');
                url = url.replace("checkout/cart","ajax/index"); 
                var data = jQuery('#product_addtocart_form').serialize();
                data += '&isAjax=1';   
                try {
                          url: url,
                          dataType: 'json',
                          type : 'post',
                          data: data,
                          success: function(data){

                                if(jQuery('.header .links')){
                                    jQuery('.header .links').replaceWith(data.toplink);
                } catch (e) {

If I add this here it redirects the page, but adds 2 items

                } catch (e) {

1 Answer 1


Redirecting AJAX requests to another url does not affect the original page. The most simple solution would be to redirect using javascript on when AJAX result is returned.

success: function(data){
         //perform checks if needed
         window.location.href = '<?php echo Mage::getUrl("checkout/cart");?>';
  • can this be in M2 ?
    – Ajwad Syed
    Commented Nov 16, 2018 at 7:10

Your Answer

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

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