$(document).ready(function(){ if(window.speechSynthesis !=undefined) { var msg = new SpeechSynthesisUtterance("请输入用户名和密码"); window.speechSynthesis.speak(msg); } $("#loginbutton").click(function(){ var username = document.getElementById('username').value; var password_user = document.getElementById('password').value; var json={ "success":true, "detail": {"student_number":"123456","password":"123456","state":"1","last_login_time":"2020-07-22 18:49:32"} }; if((username == "XiDian" && password_user=="XiDian2021...")){ sessionStorage.setItem("username",username); sessionStorage.setItem("password",password_user); if(window.speechSynthesis !=undefined) { msg = new SpeechSynthesisUtterance("登录成功!"); window.speechSynthesis.speak(msg); } // alert(json.detail.student_number+" "+json.detail.password); //window.close(); //window.open('index.html') window.location.href="index.html"; } else{ if(window.speechSynthesis !=undefined) { var msg = new SpeechSynthesisUtterance("用户名密码错误!"); window.speechSynthesis.speak(msg); } alert("用户名密码错误"); $("#errormessage").css('display','block'); //$("#errormessage").hide(); } }); }); /* $(document).ready(function(){ $("#loginbutton").click(function(){ $.post("user/login", { student_number:$('#username').val(), password:$('#password').val() }, function(data,status){ //alert("数据: \n" + data + "\n状态: " + status); if(status=="success") { var json=data; if(json.success == true){ // window.location.href="datamanage.html"; sessionStorage.setItem("username",json.detail.student_number); sessionStorage.setItem("password",json.detail.password); //window.close(); //window.open('datamanage.html') window.location.href="index.html"; //alert(json.detail.student_number+json.detail.password) } else{ $("#errormessage").css('display','block'); } } else { alert("请求失败,请重试!"); } }); }); }); */