为什么这样做 var password=$("input[name=password]").val();获取不到值
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>{$title}</title></head...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{$title}</title>
</head>
<body>
<form action="" method="post" id='myform'>
<input type="text" name="username" id="user"/><br />
<input type="text" name="password" id="pwd"/><br />
<input type="submit" value="提交" />
</form>
<script type="text/javascript" src="__PUBLIC__/Home/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
// var password=$("input[name=password]").val();
// var password=$("input[name=password]").val();
$('#myform').submit(function() {
$.post("{:U(Home/Login/checkLogin)}",{password:password,username:username},function(data){
console.log(data);
});
return false;
});
</script>
</body>
</html> 展开
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{$title}</title>
</head>
<body>
<form action="" method="post" id='myform'>
<input type="text" name="username" id="user"/><br />
<input type="text" name="password" id="pwd"/><br />
<input type="submit" value="提交" />
</form>
<script type="text/javascript" src="__PUBLIC__/Home/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
// var password=$("input[name=password]").val();
// var password=$("input[name=password]").val();
$('#myform').submit(function() {
$.post("{:U(Home/Login/checkLogin)}",{password:password,username:username},function(data){
console.log(data);
});
return false;
});
</script>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询