如何使用ajax 提交easyUI form表单
HTML代码:
<form id="Login" method="post">
...
</form>
JS代码如下:
$(function(){
$("#log").click(function(){ $("#Login").form("submit",{ url:"LoginServlet", onSubmit: function(){ var s= $("#Login").form("validate"); if(s){ return true; }else{ $.messager.alert("提示","信息填写不完整","info"); return false; } }, success:function(data){ var data1 = eval("("+data+")"); if(data1.success){ window.location.href="indexZhu.jsp"; }else if(data1.error){ $.messager.alert("提示","用户名或密码错误","info"); }else if(data1.success1){ $.messager.alert("提示","登录通道错误!","info"); }else{ $.messager.alert("提示","请输入完整的信息","info"); } } }); });
});