我正在为我的网站创建一个AJAX日志表格; 但是,我遇到了一些我认为是jQuery中的错误的东西.
代码示例:
<!DOCTYPE html>
<html>
<head>
<title>Log In</title>
</head>
<body>
<div class="errors"></div>
<input type="username" placeholder="username">
<input type="password" placeholder="password">
<input type="submit" value="Log In">
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script>
$('input[type=submit]').click(function(){
$(".errors").load(window.location.protocol + "//" + window.location.host + "?username=" + $("input[type=username]").val() + "&password=" + $("input[type=password]").val());
return false;
});
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
我知道这不是服务器端问题.返回值为$("input[type=username]").val()
is undefined
,而返回值为$("input[type=password]").val()
输入值.谢谢大家!:)