Uncaught TypeError: Cannot set property 'unobtrusive' of undefined

后端 未结 2 501
时光取名叫无心
时光取名叫无心 2020-12-09 07:43

I am getting this error in the Chrome JScript debugger. It happened when I switched to the Microsoft CDNs for the scripts below.

I\'m not sure how to work around t

相关标签:
2条回答
  • 2020-12-09 08:07

    Another reason this error can occur is if you load the unobtrusive script before jquery.validate.

    So,

    <script src="/scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="/scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
    

    is OK, but:

    <script src="/scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
    <script src="/scripts/jquery.validate.min.js" type="text/javascript"></script>
    

    will give the "Cannot set property 'unobtrusive' of undefined" error.

    0 讨论(0)
  • 2020-12-09 08:13

    Found it. I was missing two lines:

    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/additional-methods.min.js"></script>
    

    I learned this by reading this page which describes how the jquery.validate.unobtrusive script works.

    0 讨论(0)
提交回复
热议问题