/**
* 表單提交校驗
**/
function onSubmit(){
if($(
alert("名稱請不少於兩個漢字");
return false;
}
var t = new Date()
$
type: "POST"
url: "/users/checkrepeat/"
data: "name=" + $(
success:function(res){
if(res ==
alert("名稱已存在
return false;
}
}
});
}
問題原因
修改後的代碼
/**
* 表單提交校驗
**/
function onSubmit(){
if($(
alert("名稱請不少於兩個漢字");
return false;
}
var flag = true;
var t = new Date()
$
type: "POST"
async:false
cache:false
url: "/users/checkrepeat/"
data: "name=" + $(
success:function(res){
if(res ==
alert("名稱已存在
flag = false;
}
}
});
if(!flag)
return false;
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19889.html