Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC5, AjaxHelper, and the Correct Scripts & Load Order

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.

like image 283
Alex Pearlstein Avatar asked May 27 '14 17:05

Alex Pearlstein


1 Answers

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.

like image 188
Jasen Avatar answered Sep 25 '22 00:09

Jasen