I realised that in my MVC5 project in Visual Studio I could not get the Ajax.BeginForm to work properly. It will always do a full postback.
I was trying to complete a Video Rating Page, where there are buttons to rate a video and once the user presses one of the rating button, it should thank the user and display the new rating value. I wanted this to shown on the same page without reloading the page, So I considered using AJAX.BeginForm which will simply work fine.
In order to have this AJAX functionality you will have to download the AJAX from NUGET.
Install the following two highlighted packages from NUGET. Click here to check how to load Packages from NUGET in Visual Studio
Once you have installed the above two packages through NUGET then do the following.
Go to the _Layout file in your _shared folder in the Views. ( Note that I am using VB.NET but the example will work for C# also.
Open the _Layout.vbhtml file and browse to the bottom.
You will see the following two lines.
Now add the following line after the above two lines.
I made a mistake of adding this script at the top of my page and my AJAX calls refused to work.
Then I realised that the AJAX has to be loaded after loading the jquery. So I added it at the last.
Run your application.
Your AJAX Calls should work fine.