简体   繁体   English

jQuery Ajax不传递参数

[英]jquery ajax not passing parameters

I've used ajax before, but this time the ajax is not passing the parameters, I've already tried some solutions, but can't solve this. 我以前用过的阿贾克斯,但这次的Ajax不是传递参数,我已经尝试了一些解决方案,但解决不了这个。

jQuery jQuery的

 $('.entrar').click(function(){
        event.preventDefault();
        if (check_login()){

            var dataLogin;
            var manter_ligado;

            if ($('#mantem_login').is(':checked'))
            {
                manter_ligado = "1";
            } else {
                manter_ligado = "0";
            }

            dataLogin = 'mail=' + $('#login_mail').val() + '&pass=' + $('#login_password').val() + '&on=' + manter_ligado;

            $.ajax({
                  url: 'modules/login.php',
                  type: 'POST',
                  //data: dataLogin,
                  data : ({
                            mail : $('#login_mail').val(),
                            pass : $('#login_password').val(),
                            on : manter_ligado
                         }),
                  success: function(data) {
                    alert('Login efectuado com sucesso.');
                    console.log(data);
                  },
                  error: function(xhr, textStatus, errorThrown) {
                    alert('Login nao entrou');
                    console.log(xhr.statusText);
                    console.log(textStatus);
                    console.log(error);
                  }
                });

            return false;

        }

    })

this is HTML 这是HTML

        <span class="title">Entrar na sua conta</span>

        <input name="login_mail" placeholder=" e-mail" id="login_mail" type="email" class="email text_box"/>
        <input name="login_password" placeholder="password" id="login_password" type="password" class="password text_box" />
        <span>Perdeu a password?</span>

        <div class="mantem_login">
            <input name="mantem_login" id="mantem_login" type="checkbox" class="mantem_login" />
            <label for="mantem_login"><span class="mantem_login">Manter-me conectado</span></label>
        </div>


        <input type="submit" name="entrar" class="submit_button entrar" id="entrar" value=""  />

    </div>
</form>

What can I do so that the parameters get to the url? 我能做些什么,这样的参数得到的网址是什么?

Remove the round brackets from your parameter value: 从参数值中删除圆括号:

data: {
    mail : $('#login_mail').val(),
    pass : $('#login_password').val(),
    on : manter_ligado
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM