加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax异步验证

发布时间:2020-12-16 02:05:52 所属栏目:百科 来源:网络整理
导读:提交表单时,异步验证 var name = $("#name").val(); $.ajax({ type: "Post", url: "router-agent!checkName.do", data: "routerAgent.name="+encodeURIComponent(name),//字符格式转换,如果是汉字之类 的参数需要转码 dataType:"text", async:false, succe

提交表单时,异步验证

var name = $("#name").val();

$.ajax({

type: "Post",
url: "router-agent!checkName.do",
data: "routerAgent.name="+encodeURIComponent(name),//字符格式转换,如果是汉字之类 的参数需要转码
dataType:"text",
async:false,
success: function(result){

if(result != null && result != ""){
if(result=="yes"){
alert("手机号码:"+name+"已经存在");
}else{
loading();
submitForm("addform");
}
}
},
error:function(){
alert("网络连接超时!");
}

});


后台action

public String checkName() throws HtjxException { String result = ""; if (routerAgentService.checkAgentName(routerAgent.getName()) == null) { result = "no"; } else { result = "yes"; } outPrint(result); return null; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读