SpringMVC项目中使用Google Kaptcha 生成验证码(2)

1 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 3 <html> 4 <head> 5 <script src="https://www.linuxidc.com/${pageContext.request.contextPath}/js/jquery.min.js" type="text/javascript"></script> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 生成的验证码:<img src="https://127.0.0.1/captcha/getCaptchaCode.htm"> <a href="javascript:changeCaptcha()">看不清,换一张</a> 11 <br> 12 <br> 13 请输入验证码:<input type="text"> <input type="button" value="提交验证"> 14 </body> 15 <script type="text/javascript"> 16 //获取验证码图片 17 function changeCaptcha(){ 18 $("#changeCaptcha").attr("src","https://127.0.0.1/captcha/getCaptchaCode.htm"); 19 } 20 //验证输入的验证码 21 function checkCaptcha(){ 22 var captchaCode = $("#captchaCode").val(); 23 $.ajax({ 24 type:'post', 25 async : false, 26 url:'http://127.0.0.1/captcha/checkCaptchaCode.htm', 27 data:{"captchaCode" : captchaCode}, 28 success:function(res){ 29 alert(res); 30 } 31 }); 32 } 33 </script> 34 </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/fe59939a44aeb256502b01c2d332006e.html