jquery - 加载时不引人注目的验证 javascript 错误 - $jQval 未定义
我将其与 jquery 1.7 一起使用。我不断收到 - jQval is undefined
错误。
这就是我加载脚本的方式。
$.ajax({
url: "http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js",
dataType: "script",
cache: true,
success: callback
});
我也尝试将其直接加载到头部 - 同样的错误
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js" type="text/javascript"></script>
I am using this with jquery 1.7. I keep getting - jQval is undefined
error.
This is how i am loading the script.
$.ajax({
url: "http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js",
dataType: "script",
cache: true,
success: callback
});
I also tried loading it directly in the head - same error
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.js" type="text/javascript"></script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是为其他从搜索中到达这里的人发帖...
在头部加载文件时出现错误的原因是 jquery.validate.unobtrusive 需要 jquery.validate。这就是导致错误的原因。
(即,仔细检查您是否在 jquery.validate.unobtrusive 之前成功包含 jquery.validate)
Just posting for anyone else getting here from a search...
The reason you were getting the error when loading the files in the head is that jquery.validate.unobtrusive requires jquery.validate. That's what was causing the error.
(ie, double-check that you're successfully including jquery.validate before jquery.validate.unobtrusive)
已解决
级联 ajax 加载调用解决了它。它看起来像是加载两个文件的计时问题
Solved
Cascading the ajax load calls solved it.. it looks like a timing issue on loading the two files
以下 3 个脚本对我来说非常有用:
假设您有一个表单:
键入视图模型:
The following 3 scripts work great for me:
Assuming you have a form:
typed to a view model: