gpt4 book ai didi

jquery - ajax请求表现得很奇怪

转载 作者:行者123 更新时间:2023-12-01 08:11:22 25 4
gpt4 key购买 nike

我在发送变量和 ajax 请求时遇到困难。这是我的 html/js 代码:

    <input id="login-username" class="input" type="text" placeholder="Username"/>

<input id="login-password" class="input" type="password" placeholder="Password"/>

<a href="javascript:void(0);" id="submit-login" class="btn btn-small btn-info"><strong>sign in</strong></a>

$("#submit-login").click(function(e){
e.preventDefault();
var usernameReg = /^[a-zA-Z0-9]+$/;
var username = $("#login-username").val();
var password = $("#login-password").val();
alert(username);
alert(password);
if(!usernameReg.test(username)){
$("#input-login-username").html("some html");
return false;
} else if(!usernameReg.test(password)){
$("#input-login-password").html("some html");
return false;
} else if((username == "") || (password = "")){
$("#input-login-username").html("<strong><small>Empty field(s)</small></strong>");
return false;
} else {
$.ajax({
type: 'POST',
url: '?a=validate',
data: {
"password" : password,
"username" : username
},
success: function(data){
some statements
}
});
}
});

enter image description here

enter image description here

接收密码元素的值,如第一张图像中所示。并且通过 ajax 发送的对象文字中没有拼写错误。我做错了什么?

最佳答案

===:

} else if((username == "") || (password = "")){

关于jquery - ajax请求表现得很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13445631/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com