$(document).ready(function(){ //ajax登录 $("#loginb").click(function(){ var username = $("#usename").val(); var password = $("#pasword").val(); $.ajax({ url:"${ctx}/login", //url自行更换 type:"post", data:"username="+username+"&password="+password, dataType:"json",//视情况而定 async : true, success:function(data){ if(data.success==1){ window.location.reload(); }else { alert("用户名或者密码错误!"); window.location.reload(); } } }); }); //ajax登录结束 }