MVC5, AjaxHelper, and the Correct Scripts & Load Order

匿名 (未验证) 提交于 2019-12-03 02:08:02

问题:

OK, I find it EXTREMELY ridiculous that I have to post a new question to find the answer but, alas here I am. Let's make this as simple as possible for the next wayward soul looking to resolve this.

What are all the most current scripts I require to get the ajax form working? Thus far I have;

<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.js"></script> <script src="//ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script> <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.12.0/jquery.validate.js"></script> <script src="//ajax.aspnetcdn.com/ajax/mvc/5.0/jquery.validate.unobtrusive.min.js"></script>

I have seen pages that state I need jquery.unobtrusive-ajax.js as well, but that just gives me an error. Do I have some incompatible versions loaded?

I've worked with this several times in the past for MVC3 etc, but it's just silly that I cannot seem to find a simple page explaining the code expectations for the current version.

Thank you in advance to anyone who can help me remove my head from where it appears to be firmly stuck this afternoon.

回答1:

The very minimum you need for AjaxHelper

NuGet Package Microsoft jQuery Unobtrusive Ajax 3.1.2

> Install-Package Microsoft.jQuery.Unobtrusive.Ajax -Version 3.1.2

Now include the scripts

<script src="~/jquery-1.11.0.js"></script> <script src="~/jquery.unobtrusive-ajax.js"></script>

Go ahead and get the latest version if available. I specified v3.1.2 to demonstrate that the AjaxHelper worked for at least this particular version at a particular time.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!