浏览器报错
Jquery位置如下
html如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>获取验证码</title>
<script src="asserts/js/jquery-2.1.0.min.js" type="text/javascript"></script>
</head>
<body>
<div>
<h3>获取otp信息</h3>
<div>
<label>手机号</label>
<div>
<input type="text" placeholder="手机号" name="telphone" id="telphone">
</div>
</div>
<div>
<button id="getotp" type="submit">
获取otp短信
</button>
</div>
</div>
</body>
<script>
$(function () {
$("#getotp").click(function () {
$.ajax({
type:"POST",
contentType:"application/x-www-form-urlencoded",
url:"http://localhost:8081/user/getotp",
data:{
"telphone":$("#telphone").val()
},
success:function (data) {
if(data.status=="success")
{
alert("otp已经发送到您的手机上请注意查收");
}else
{
alert("otp发送失败原因为"+data.data.errMsg)
}
},
fail:function (data) {
alert("otp发送失败"+data.responseText);
}
})
})
})
</script>
</html>