代码如下:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<script type="text/javascript" src="jquery-3.1.1.js"></script>
<script type="text/javascript">
function loginAjax() {
var userName = document.getElementById('Name');
var password = loginform.password.value;
alert("UserName:" + userName.value + "PassWord:" + password);
$.ajax({
url: "Check",
dataType: "text",
type: "POST",
data: "userName=" + userName.value + "&password=" + password,
success: function (da) {
alert(da);
},
})
}
$("#sub").onclick(function () {
var userName = document.getElementById('Name');
var password = loginform.password.value;
alert("UserName:" + userName.value + "PassWord:" + password);
$.ajax({
url: "Check",
dataType: "text",
type: "POST",
data: "userName=" + userName.value + "&password=" + password,
success: function (da) {
alert(da);
},
})
})
$(document).ready(function () {
function lalala() {
alert("dawoa erzi ")
}
})
</script>
<title>tryAJAX</title>
</head>
<body>
<form id="loginform" name=" loginform">
用户:<input type="text" id="Name" name="username"/><br/>
密码:<input type="password" id="password" name="password"/><br/>
<input type="submit" value="登录1" onclick="loginAjax()"/>
<input type="button" id="sub" value="登录2"/>
<input type="button" id="sub01" value="登录3" onclick="lalala()"/>
</form>
</body>
</html>
每个按钮试了一种方法,但是都不行, 只要是jquery的东西完全都不执行,大神,让我抱抱你的腿
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<script type="text/javascript" src="jquery-3.1.1.js"></script>
<script type="text/javascript">
function loginAjax() {
var userName = document.getElementById('Name');
var password = loginform.password.value;
alert("UserName:" + userName.value + "PassWord:" + password);
$.ajax({
url: "Check",
dataType: "text",
type: "POST",
data: "userName=" + userName.value + "&password=" + password,
success: function (da) {
alert(da);
},
})
}
$("#sub").onclick(function () {
var userName = document.getElementById('Name');
var password = loginform.password.value;
alert("UserName:" + userName.value + "PassWord:" + password);
$.ajax({
url: "Check",
dataType: "text",
type: "POST",
data: "userName=" + userName.value + "&password=" + password,
success: function (da) {
alert(da);
},
})
})
$(document).ready(function () {
function lalala() {
alert("dawoa erzi ")
}
})
</script>
<title>tryAJAX</title>
</head>
<body>
<form id="loginform" name=" loginform">
用户:<input type="text" id="Name" name="username"/><br/>
密码:<input type="password" id="password" name="password"/><br/>
<input type="submit" value="登录1" onclick="loginAjax()"/>
<input type="button" id="sub" value="登录2"/>
<input type="button" id="sub01" value="登录3" onclick="lalala()"/>
</form>
</body>
</html>
每个按钮试了一种方法,但是都不行, 只要是jquery的东西完全都不执行,大神,让我抱抱你的腿