先上一个能用的js代码:
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); } }); }