.mui.ajax的写法:
var inpt_mobile = document.getElementById("inpt_mobile"); var inpt_pwd = document.getElementById("inpt_pwd"); url:"http://***.***.***.***:8080/Smart_Toilet2/a", type:‘post‘, data:{ username:inpt_mobile.value, password1:inpt_pwd.value, }, dataType:‘text‘, timeout:10000, success:function(res){ }, //异常处理 error:function(e){ console.log(e); } })
servlet的写法:
String a = request.getParameter("username");
System.out.print(a);
获取后台数据mui.ajax的写法:
function login() { var uname=document.getElementById("username").value.trim(); var pwd=document.getElementById("password").value.trim(); mui.toast("0 "+uname+" "+pwd); mui.ajax( ‘http://192.168.63.2:8080/ServletTest/servlet/AjaxTest‘,{ data: { uname:uname, pwd:pwd }, dataType: ‘text‘, type: ‘post‘, timeout: 10000, headers: { ‘Content-Type‘: ‘application/x-www-form-urlencoded‘ }, success: function(data) { mui.toast("success "+data); }, error: function(xhr, type, errorThrown) { mui.toast("error "+type); console.log(xhr,type,errorThrown); } }); }