$.validator.addMethod("checkUsername",
function(value, element){
var test; //we want to use this test is like boolean variable
$.ajax({
type:"GET",
data: 'name='+ value,
url: "master/ValidationDepartment.jsp",
success: function(response){
test = true; //assign this value is true
},
error: function() {
test = false; //assign this value is false
}
});
//alert(test); // bt now this time test value is undifined
return test;
},
"Departmentname Already Exists."
);
});
私も試してみましたvar test = true
。test = true
その値が true になるたびに宣言するとします。