1.表格提交執行自定義ajax,最後須要加上renturn false;ajax
示例:form.on("submit(formLogin)",function(datas){
var data=datas.field;
$.ajax({
type:'post',
url:"http://localhost/moneyManage/public/admin/login/logins",
data:data,
dataType:"json",
success:function(res){
if(res==0){
layer.msg("帳號或密碼輸入錯誤,請從新輸入!!",{
icon: 2,
time: 2000 //2秒關閉(若是不配置,默認是3秒)
},function(){
location.href="http://localhost/moneyManage/public/admin/login";
layer.close(index);
});
}else if(res==1){
layer.msg("恭喜您,登陸成功!!",{
icon: 1,
time: 2000 //2秒關閉(若是不配置,默認是3秒)
},function(){
window.location.href="http://localhost/moneyManage/public/admin/common/index";
layer.close(index);
});
}
},
error:function(res){
layer.msg("網絡錯誤!!",{
icon: 2,
time: 2000 //2秒關閉(若是不配置,默認是3秒)
},function(){
layer.close(index);
window.location.href="http://localhost/moneyManage/public/admin/login";
});
}json
})網絡
return false;,//不添加就不會執行ajax
});post