douzui0143 2019-07-19 11:06
浏览 363

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();
  });
});
  • 写回答

4条回答 默认 最新

  • drutcs7210 2019-07-19 11:47
    关注

    Store your url in a variable then call this line.

    var url = "your current url";
    $(location).attr('href',url);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?