buyerAction 中,有一个searchName()方法,返回 boolean 类型。在 register.jsp 页面中:
<script type="text/javascript">
function checkName(){
//请求 的 是 Struts2 的 action.
$.post("buyer/buyerAction_searchName",{username : $("#vipName").val()},callback);
}
function callback(isRoot){
if(isRoot){
alert(isRoot);
}
</script>结果 打印出来的 是 报错信息: 大体意思是 不能 把 boolean 转换为 String.
如何 处理?
<script type="text/javascript">
function checkName(){
//请求 的 是 Struts2 的 action.
$.post("buyer/buyerAction_searchName",{username : $("#vipName").val()},callback);
}
function callback(isRoot){
if(isRoot){
alert(isRoot);
}
</script>结果 打印出来的 是 报错信息: 大体意思是 不能 把 boolean 转换为 String.
如何 处理?
if(isRoot){
alert(isRoot);
}else{
alert("aaaa")
}
它 只执行 isRoot 为true 不执行
else 里的东西。
有点伤脑筋啊。