惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
S
Schneier on Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Recorded Future
Recorded Future
I
Intezer
云风的 BLOG
云风的 BLOG
博客园 - Franky
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
The Hacker News
The Hacker News
T
The Blog of Author Tim Ferriss
Attack and Defense Labs
Attack and Defense Labs
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
News and Events Feed by Topic
有赞技术团队
有赞技术团队
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
The Cloudflare Blog
Webroot Blog
Webroot Blog
W
WeLiveSecurity
H
Heimdal Security Blog
博客园 - 三生石上(FineUI控件)
V
Vulnerabilities – Threatpost
G
Google Developers Blog
O
OpenAI News
V
V2EX
罗磊的独立博客
博客园_首页
N
News | PayPal Newsroom
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
TaoSecurity Blog
TaoSecurity Blog
Cloudbric
Cloudbric
H
Hacker News: Front Page
博客园 - 叶小钗
T
Tor Project blog
AI
AI

博客园 - 天天无用

jsonp原理实例及mvc中的应用 ubuntu笔记 诺基亚手机S60系统证书申请、软件签名图文教程 JAXER留言板-一个html页面的ajax留言版 - 天天无用 - 博客园 初探JAXER Jquery插件研究:Ajax File Upload 本月wii游戏太多,感觉有点堕落 使用jQuery加DIV实现可以动态添加的金字塔结构 自制的操作下拉列表框(SELECT)的三个jquery插件(ajax填充、联动、增加选项) - 天天无用 - 博客园 Asp.net 2.0 TreeView控件使用jQuery无刷新添加节点详细说明 用jQuery实现.net 2.0 treeview客户端无刷新操作的实例 基于jQuery的AJAX和JSON实现纯html数据模板 自己写的DataTable转换成JSON字符串的函数 自己写的jQuery自动完成的插件(AutoComplete) asp.net treeview控件无刷新选择和删除节点(使用jquery) - 天天无用 - 博客园 纵向合并gridview单元格的两种方法 .net下两种json序列化速度比对 asp.net 2.0 中 TreeView控件中的checkbox客户端操作 asp.net 2.0中根据roles显示不同的sitemap - 天天无用 - 博客园
修复MVC3中使用Remote验证的一点小问题
天天无用 · 2011-04-24 · via 博客园 - 天天无用

MVC3中使用Remote验证,把jquery1.4.4换成1.5.2后验证不起作用,而且无法提交表单。

排查后是因为ajax请求后返回数据类型的问题

修改jquery.validate.js,从939行开始,加注释的两行为修改的地方

$.ajax($.extend(true, {
                        url: param,
                        mode: "abort",
                        port: "validate" + element.name,
                        //dataType: "json",//这里注释掉
                        data: data,
                        success: function (response) {
                            alert(response);
                            validator.settings.messages[element.name].remote = previous.originalMessage;
                            var valid = response === "true";//这里把true加上引号
                            if (valid) {

类中属性定义

        [Required]
        [Display(Name="游戏ID")]
        [Remote("CheckGameId","Mdata",ErrorMessage="游戏ID已存在")]
        public int GameId { get; set; }

进行验证的方法直接返回string类型即可

        public string CheckGameId(int gameId)
        {
            appData ad = new appData();
            if (!ad.CheckGameId(gameId))
                return "true";

            string errorMsg = gameId + "已存在";
            return errorMsg;
        }