北城已荒凉 2016-09-21 14:28 采纳率: 0%
浏览 354

在Ajax中传递URL变量

I'm sure if I'm going about this the right way, but I need to pass the form variables in the URL redirect. The redirect is working, but I can't get the data to output.

$("#promoForm").on('submit', function(e) {
    e.preventDefault();
    var data = {
        firstname: $("#firstname").val(),
        lastname: $("#lastname").val(),
        email: $("#email").val(),
        code: $("#code").val()
    };

    if ( isValidEmail(data['email']) && (data['firstname'].length > 1) && (data['lastname'].length > 1) && (data['code'].length > 1) ) {
        $.ajax({
            type: "POST",
            url: "php/promo.php",
            data: data,
            success: function() {
                $('.success.pf').delay(500).fadeIn(1000);
                $('.failed.pf').fadeOut(500);
                setTimeout(function() {
                  window.location.href = "http://demo.example.com/signup?firstname=+data['firstname']+lastname=+data['lastname']+email=+data['email']+code=+data['code']"
                }, 3000);
            }
        });
    } else {
        $('.failed.pf').delay(500).fadeIn(1000);
        $('.success.pf').fadeOut(500);
    }

    return false;
});
  • 写回答

2条回答 默认 最新

  • weixin_33704234 2016-09-21 14:32
    关注

    Try this,

    window.location.href = "http://demo.example.com/signup?firstname="+data['firstname']+"lastname="+data['lastname']+"email"=+data['email']+"code="+data['code']
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?