ajax.begin form onsuccess is not working asp.net mvc

Hi friends, I have faced this problem while development and found the solution after spending 2 hours. First I get the solution like I have to add <script src=”~/Scripts/jquery.unobtrusive-ajax.js”></script> file into the code and add <add key=”UnobtrusiveJavaScriptEnabled” value=”true” /> key in web.config file.

I done this and try to run the application but then get error undefined is not a function over the jquery.unobtrusive-ajax.js file. I was using jquery version higher than 1.9.

The reason of this error is .live() function of the jquery.unobtrusive-ajax.js file was deprecated and not compatible with Jquery 1.9+.

Fix Ajax.BeginForm doesn’t call onSuccess

You have to add simple a jquery-migrate: Migrate older jQuery code to jQuery 1.9+. This plugin can be used to detect and restore APIs or features that have been deprecated in jQuery and removed as of version 1.9.

<script src=”http://code.jquery.com/jquery-1.9.0.js”></script>
<script src=”http://code.jquery.com/jquery-migrate-1.2.1.js”></script>
<script src=”@Url.Content(“~/Scripts/jquery.unobtrusive-ajax.min.js”)” type=”text/javascript”></script>

Hope this will save your time…

Happy coding…

Posted by | View Post | View Group