JqueryValidate remote的用法
首先知道,remote请求的controller只能返回String或boolen型的true 或者 false
userPhone: {
remote: "${ctx}/register/checkUserPhone?userPhone="+$("#userPhone").val()
}
以上代码发送的请求:http://localhost:8080/register/checkUserPhone?userPhone=&userPhone=15032108332
userPhone: {
remote: "${ctx}/register/checkUserPhone"
}
以上代码发送的请求:http://localhost:8080/register/checkUserPhone?userPhone=15032108332
由此证明,remote会自动像地址后边拼接 name="userPhone"的input的值作为参数传递
标准写法:
userPhone: {
remote: {
url: "${ctx}/register/checkUserPhone",
type: "get",
data:{
userPhone:function(){
return $("#userPhone").val();
}
}
}
}
此外遇到的问题:当项目中用到了shiro,要注意remote请求地址会被shiro拦截,开始时shiro配置:
/register = anon
发现remote未起作用,并且不报错
因为remote请求register的次级地址,所以shiro配置应为:
/register/** = anon
哎这种地基问题折腾半天。。。。
开始的时候,我们以为我们什么都知道,但后来发现,事实是我们什么都不知道---麦克阿瑟
點擊查看更多內容
1人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦