window.location.href在ajax成功后无法正常工作

In this code I am using razorpay payment gateway api where payments are successfully done but not able to redirect after success ajax call. So, How can I redirect page using window.location.href in order page? Please help me.

$(document).ready(function() {
  $('#buy_now').click(function(e) {
    var total_amount = $(".total_amount").val();
    var product_id = $(".product_id").map(function() {
      return this.id;
    }).get().join(",");
    var new_uid = $("#new_uid").val();
    var user_id = $("#uid").val();
    var user_email = $(".user_email").attr("id");
    var options = {
      "key": "************************",
      "amount": (1 * 100), // 2000 paise = INR 20
      "name": "MyApp",
      "description": "Payment",
      "image": "https://www.MyApp.com/img/logo/logo.png",
      "handler": function(response) {
        $.ajax({
          url: '<?php echo base_url() ?>razorPaySuccess',
          type: 'post',
          dataType: 'json',
          data: {
            "razorpay_payment_id": response.razorpay_payment_id,
            "total_amount": total_amount,
            "product_id": product_id,
            "new_uid": new_uid,
            "user_email": user_email,
            "user_id": user_id
          },
          success: function(data) {
            window.location.href = "<?php echo base_url(); ?>order";
          }
        });
      },
      "theme": {
        "color": "#528FF0"
      }
    };
    var rzp1 = new Razorpay(options);
    rzp1.open();
    e.preventDefault();
  });
});

Store your url in a variable then call this line.

var url = "your current url";
$(location).attr('href',url);
window.location.href = window.location.href; it may work for you.

Do like this:-

var path = "<?php echo base_url(); ?>";
window.location.href = path+"order";

So far i didn't noticed any mistake of your code.. you just make sure that it goes to success: function() and use window.location.replace not window.location.href. So it will replace the current url and redirect you to your success page.

window.location.replace = "<?php echo base_url(); ?>order";

If that code above still don't work. your e.preventDefault() can cause you preventing to redirect to your success page so make sure to use it accordingly.